Schedule Microsoft Access Synchronization

  • Thread starter Thread starter flcaptainbill
  • Start date Start date
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>
 
try creating a function like the following

Public Function Run()
RunReplication("E:\Database Masters\Master.mdb","e:\Databases\Replica.mdb","admin","")
End Function

and see if it will run that as a function in the macro
 
Workmad3,

Thanks for the quick reply

When creating that new function I get a VB compile error: Expected:=

Added =True to the end.

Now I get the error
Can't open database. It may not be a database that your applicaiton recognizes, or th efile may be corrupt.
 
Last edited:
Did you ever figure out how to do this?

I want to do the same and still in the process of finding it.
 
Yes I got it figured out. I wrote a VB app to do it. I then schedule the .exe.
 

Users who are viewing this thread

Back
Top Bottom