kapotocho
Messages postés18Date d'inscriptionjeudi 29 novembre 2007StatutMembreDernière intervention16 janvier 2008
-
24 déc. 2007 à 09:39
kapotocho
Messages postés18Date d'inscriptionjeudi 29 novembre 2007StatutMembreDernière intervention16 janvier 2008
-
24 déc. 2007 à 14:22
Function cdane(aec)
Dim dbs As DAO.Database, atable As Recordset, rs As DAO.Recordset
Dim j, k, m As Integer
Dim cum, cda As Long
Static tota(99)
Set dbs = CurrentDb
Set atable = dbs.OpenRecordset("liste des cols", dbOpenSnapshot)
Set rs = dbs.OpenRecordset("cdparan", dbOpenTable, dbDenyRead)
rs.Index = "PrimaryKey"
For j = 0 To 99
tota(j) = 0
Next
Do Until atable.EOF
cda = cdan(atable![Cols Durs années précéd], atable![altit], atable![année], atable![cd], aec)
atable.MoveNext
For j = 0 To 99
tota(j) = tota(j) + totcd(j)
Next
Loop
cum = 0
For j = 0 To 99
rs.MoveFirst
rs.Edit
rs.Seek "=", j
rs![Mpan] = tota(j)
rs![An 2000] = (j + 40) Mod 100 + 1960
rs.Update
' Debug.Print j, tota(j)
cum = cum + tota(j)
cdane = cum
Next
rs.Edit
rs.Seek "=", 100
rs![Mpan] = cum
rs.Update
rs.Close
End Function
kapotocho
Messages postés18Date d'inscriptionjeudi 29 novembre 2007StatutMembreDernière intervention16 janvier 2008 24 déc. 2007 à 09:42
j'ai un soucis avec un bout de code en VBA,pouvez vouz m'aidez
ça me met l'erreur "Update ou cancelUpdate effectué sans appeler Addnew ni Edit", mais il y a un Edit!!!
le soucis est dans le for ( la ligne soulignée).
merçi d'avance et bonne fêtes de fin d'année
For j = 0 To 99
rs.MoveFirst
rs.Edit
rs.Seek "=", j
rs![Mpan] = tota(j)
rs![An 2000] = (j + 40) Mod 100 + 1960
rs.Update
' Debug.Print j, tota(j)
cum = cum + tota(j)
cdane = cum
Next