1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
Sub CopyMemeTable(strtable0, stridExt0, stridInt0 As String, ChoixDest0 As Long)
i = 0
'strtable0="tplanning",stridExt0 ="idquiouquoi", stridInt0="idplanning",
Dim sqltable0 As String
sqltable0 = "select " & strtable0 & ".* From " & strtable0 & " WHERE " & strtable0 & ".cocheselection=true"
Dim rstdepart0 As DAO.Recordset
Set db = CurrentDb
Set rstdepart0 = db.OpenRecordset(sqltable0)
If rstdepart0.EOF Then Exit Sub
rstdepart0.MoveLast
rstdepart0.MoveFirst
Dim rstarrivee0 As DAO.Recordset
Set rstarrivee0 = db.OpenRecordset(strtable0)
Dim compteur0 As Integer
Dim fld As DAO.Field
For compteur0 = 1 To rstdepart0.RecordCount
rstarrivee0.AddNew
For Each fld In rstdepart0.Fields
If fld.Name <> stridExt0 And fld.Name <> stridInt0 Then
rstarrivee0.Fields(fld.Name) = fld.Value
End If
Next
'''''''''''''''''''''''Recuperationdes donnees pour cascade
Dim IdIntA0 As Long
Dim idIntD0 As Long
IdIntA0 = rstarrivee0.Fields(stridInt0)
idIntD0 = rstdepart0.Fields(stridInt0)
rstarrivee0.Fields(stridExt0) = ChoixDest0
rstarrivee0.Update
copy3b idIntD0, IdIntA0
rstdepart0.MoveNext
Next
'decochage
Dim rstcoche As DAO.Recordset
Set db = CurrentDb
Set rstcoche = db.OpenRecordset(strtable0)
If rstcoche.EOF Then Exit Sub
rstcoche.MoveLast
rstcoche.MoveFirst
Dim compteur As Integer
For compteur = 1 To rstcoche.RecordCount
rstcoche.Edit
rstcoche("cocheselection") = False
rstcoche.Update
rstcoche.MoveNext
Next
rstdepart0.Close
rstarrivee0.Close
rstcoche.Close
db.Close
Set rstdepart0 = Nothing
Set rstarrivee0 = Nothing
Set rstcoche = Nothing
Set db = Nothing
End Sub |
Partager