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
|
Private Sub CopierDonnees_Flexo_Rosemond_Employe_bleu( _
prmNomUser As String, _
prmMotPasse As String, _
prmCheminBaseSource As String, _
prmNomBaseSource As String, _
prmNomBaseCible As String)
Dim wkSource As Workspace
Dim wkCible As Workspace
Dim dbSource As Database
Dim dbCible As Database
Dim dbeSource As DBEngine
Set dbeSource = New DBEngine
dbeSource.SystemDB = prmCheminBaseSource & "System.mdw"
Set wkSource = dbeSource.CreateWorkspace(Format(Now(), "yyyymmddhhnnss"), prmNomUser, prmMotPasse, dbUseJet)
Set dbSource = wkSource.OpenDatabase(prmNomBaseSource, , , "MS Access;PWD=""" & prmMotPasse & """")
Set wkCible = Workspaces(0)
Set dbCible = wkCible.OpenDatabase(prmNomBaseCible)
dbCible.QueryDefs("rVider_Flexo_Rosemond_Employe-bleu").Execute
Dim rSource As Recordset
Dim rCible As Recordset
Dim f As Field
Set rSource = dbSource.OpenRecordset("Employé-Bleu")
Set rCible = dbCible.OpenRecordset("Flexo_Rosemond_Employe-bleu")
Do While Not rSource.EOF
rCible.AddNew
For Each f In rSource.Fields
rCible.Fields(f.Name) = f.Value
Next f
rCible.Update
rSource.MoveNext
Loop
rCible.Close: Set rCible = Nothing
rSource.Close: Set rSource = Nothing
dbCible.Close: Set dbCible = Nothing
wkCible.Close: Set wkCible = Nothing
dbSource.Close: Set dbSource = Nothing
wkSource.Close: Set wkSource = Nothing
Set dbeSource = Nothing
End Sub |
Partager