Programmatically run Sync Now command

  • Thread starter Thread starter Silvio
  • Start date Start date
S

Silvio

Few questions:

1. How can I programmatically run the command in
Tools\Replication\Synchronize Now?

2. After running item 1, another windows pups up asking to select the
database path to Synchronize. How can I hardcode this path and skip this
windows altogether?

3. After hitting the message from item 2 above, another message pop-up
informing that the database must be closed in order for the sync to start.
Then after pressing OK the sync finally starts.

Can all this be coded so the user can just press one button and the rest
happens automatically?

Thank you,
Silvio
 
1. How can I programmatically run the command in
Tools\Replication\Synchronize Now?
[]

Can all this be coded so the user can just press one button and
the rest happens automatically?

It's quite simple. The code below assumes you want to run the
synchronization from your front-end application MDB (you can't use
replication with an unsplit app, as it will eventually corrupt your
whole database). Replace "MyTable" with the name of one of your
linked tables.

Public Sub Synchronize(strRemoteReplica As String)
Dim dbLocal As DAO.Database
Dim strLocalReplica As String

strLocalReplica = Mid(CurrentDB.TableDefs("MyTable").Connect, 11)
Set dbLocal = DBEngine.OpenDatabase(strLocalReplica)
dbLocal.Synchronize strRemoteReplica
dbLocal.Close
Set dbLocal = Nothing
End Sub

That's it.
 
Back
Top