F
flcaptainbill
Guest
Operating Systems: 2000 Pro and XP Pro
Access Versions: XP and 2003
Using code found elseware on the internet I am trying to have two MS Access databases synchronize every night.
I have created a function that appears in Modules as RunReplication
Public Function RunReplication(TheMaster, TheRemote, UserName, Password)
Dim db As Database
Dim myDBE As DBEngine
Dim dbMyNewMdb As Database
Dim ws As Workspace
On Error GoTo Err_RunReplication
Set myDBE = New PrivDBEngine
myDBE.SystemDB = DBEngine.SystemDB
myDBE.DefaultUser = UserName
myDBE.DefaultPassword = Password
Set ws = myDBE.CreateWorkspace("ws", UserName, Password)
Set dbMyNewMdb = ws.OpenDatabase(TheMaster)
RunReplication = True
dbMyNewMdb.Synchronize TheRemote
On Error GoTo Err_RunReplication
dbMyNewMdb.Close
Set dbMyNewMdb = Nothing
Exit Function
Err_RunReplication:
MsgBox Error$, vbCritical
RunReplication = False
'End
End Function
I have a Macro called Replicate. The action of that macro is RunCode with the following in the Function Name box:
RunReplication("E:\Database Masters\Master.mdb","e:\Databases\Replica.mdb","admin","")
I get the following error when attempting to run the macro from within access:
The expression you entered has a function name that Microsoft Office Access can't find.
My Plan is to schedule the macro to run using windows task scheduler as follows:
"c:\program files\microsoft office\office\msaccess.exe" "Path to the database with macro" /x <MacroName>
Access Versions: XP and 2003
Using code found elseware on the internet I am trying to have two MS Access databases synchronize every night.
I have created a function that appears in Modules as RunReplication
Public Function RunReplication(TheMaster, TheRemote, UserName, Password)
Dim db As Database
Dim myDBE As DBEngine
Dim dbMyNewMdb As Database
Dim ws As Workspace
On Error GoTo Err_RunReplication
Set myDBE = New PrivDBEngine
myDBE.SystemDB = DBEngine.SystemDB
myDBE.DefaultUser = UserName
myDBE.DefaultPassword = Password
Set ws = myDBE.CreateWorkspace("ws", UserName, Password)
Set dbMyNewMdb = ws.OpenDatabase(TheMaster)
RunReplication = True
dbMyNewMdb.Synchronize TheRemote
On Error GoTo Err_RunReplication
dbMyNewMdb.Close
Set dbMyNewMdb = Nothing
Exit Function
Err_RunReplication:
MsgBox Error$, vbCritical
RunReplication = False
'End
End Function
I have a Macro called Replicate. The action of that macro is RunCode with the following in the Function Name box:
RunReplication("E:\Database Masters\Master.mdb","e:\Databases\Replica.mdb","admin","")
I get the following error when attempting to run the macro from within access:
The expression you entered has a function name that Microsoft Office Access can't find.
My Plan is to schedule the macro to run using windows task scheduler as follows:
"c:\program files\microsoft office\office\msaccess.exe" "Path to the database with macro" /x <MacroName>