T
TPP
The code listed below works fine with Access 97, but not when used in Access
2002. Are there compatibility issues with using the "old but good" code in
the newer version of Access? The VISITES table referenced in the code remains
unchanged between the Access 97 and 2002 version of my database. Any
suggestions?
Function Set_Rendement()
Dim DB As Database, T As Recordset
Dim S As String, OldEnv As Variant, OldVeh As Variant
Dim OldC1 As Variant, OldC2 As Variant, TotC1 As Variant, TotC2 As Variant
Dim C1 As Variant, C2 As Variant
Set DB = DBEngine.Workspaces(0).Databases(0)
S = "Select
VISITES.IDEnv,VISITES.Date,VISITES.Operation,VISITES.IDVeh,VISITES.Compt1,VISITES.Compt2"
S = S + ",VISITES.D1,VISITES.D2,VISITES.T1,VISITES.T2 From VISITES"
S = S + " Order by VISITES.IDEnv,VISITES.Date,VISITES.Operation;"
Set T = DB.OpenRecordset(S, DB_OPEN_DYNASET)
T.MoveFirst
OldEnv = -1
Do Until T.EOF
If T("IDEnv") <> OldEnv Then
OldEnv = T("IDEnv")
OldVeh = T("IDVeh")
C1 = 0
C2 = 0
TotC1 = 0
TotC2 = 0
Else
If T("IDVeh") <> OldVeh Then
C1 = 0
C2 = 0
OldVeh = T("IDVeh")
Else
C1 = T("Compt1") - OldC1
C2 = T("Compt2") - OldC2
End If
TotC1 = TotC1 + C1
TotC2 = TotC2 + C2
End If
OldC1 = T("Compt1")
OldC2 = T("Compt2")
T.Edit
T("D1") = C1
T("D2") = C2
T("T1") = TotC1
T("T2") = TotC2
T.Update
T.MoveNext
Loop
T.Close
End Function
2002. Are there compatibility issues with using the "old but good" code in
the newer version of Access? The VISITES table referenced in the code remains
unchanged between the Access 97 and 2002 version of my database. Any
suggestions?
Function Set_Rendement()
Dim DB As Database, T As Recordset
Dim S As String, OldEnv As Variant, OldVeh As Variant
Dim OldC1 As Variant, OldC2 As Variant, TotC1 As Variant, TotC2 As Variant
Dim C1 As Variant, C2 As Variant
Set DB = DBEngine.Workspaces(0).Databases(0)
S = "Select
VISITES.IDEnv,VISITES.Date,VISITES.Operation,VISITES.IDVeh,VISITES.Compt1,VISITES.Compt2"
S = S + ",VISITES.D1,VISITES.D2,VISITES.T1,VISITES.T2 From VISITES"
S = S + " Order by VISITES.IDEnv,VISITES.Date,VISITES.Operation;"
Set T = DB.OpenRecordset(S, DB_OPEN_DYNASET)
T.MoveFirst
OldEnv = -1
Do Until T.EOF
If T("IDEnv") <> OldEnv Then
OldEnv = T("IDEnv")
OldVeh = T("IDVeh")
C1 = 0
C2 = 0
TotC1 = 0
TotC2 = 0
Else
If T("IDVeh") <> OldVeh Then
C1 = 0
C2 = 0
OldVeh = T("IDVeh")
Else
C1 = T("Compt1") - OldC1
C2 = T("Compt2") - OldC2
End If
TotC1 = TotC1 + C1
TotC2 = TotC2 + C2
End If
OldC1 = T("Compt1")
OldC2 = T("Compt2")
T.Edit
T("D1") = C1
T("D2") = C2
T("T1") = TotC1
T("T2") = TotC2
T.Update
T.MoveNext
Loop
T.Close
End Function