1 2 3 4 5 6 7 8 9 10 11 12 13
| strSQL = "SELECT " + reque + ".no_affaire, "
For t = 1 To aq: strSQL = strSQL + reque + ".[" + Right(Str(code(t)), Len(Str(code(t))) - 1) + "], ": Next t
strSQL = strSQL + "Sum(nz([" + Right(Str(code(1)), Len(Str(code(1))) - 1) + "],0)"
For t = 2 To aq: strSQL = strSQL + "+nz([" + Right(Str(code(t)), Len(Str(code(t))) - 1) + "],0)": Next t
strSQL = strSQL + ") AS tot" & affect + " FROM " + reque + " "
strSQL = strSQL + "GROUP BY " + reque + ".no_affaire, "
For t = 1 To aq - 1: strSQL = strSQL + reque + ".[" + Right(Str(code(t)), Len(Str(code(t))) - 1) + "], ": Next t
strSQL = strSQL + reque + ".[" + Right(Str(code(aq)), Len(Str(code(aq))) - 1) + "];"
db.CreateQueryDef (req), strSQL
db.QueryDefs(req).Close
If IsError(db.OpenRecordset(req)) Then Stop
a3 = rs2.RecordCount
If rs2.RecordCount > 0 Then GoTo fini |
Partager