Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command Button For Synchronization

Status
Not open for further replies.

jamason07

IS-IT--Management
Aug 28, 2003
46
US
Good Morning,

I've created a command button on my main screen to make it easy for users to synch. But it isn't working correctly. I get a message saying that it can't sync because "one or more objects are open". I'm using the following code:

Private Sub Command10_Click()
RunCommand acCmdSynchronizeNow
End Sub

Suggestions?

Thanks!

JAM
 
Hi, in order to control replication I found it easiest to add a reference to Microsoft Jet and Replication Objects x.x Library and then right a couple of functions, for example
Code:
Public Sub DirectSyncToMaster()
Dim r As New JRO.Replica
    
On Error GoTo err_handler

r.ActiveConnection = GetMasterConnection

r.Synchronize CurrentProject.FullName, jrSyncTypeImpExp, jrSyncModeDirect

Exit Sub

err_handler:
Select Case Err.Number
    Case -2147467259        'The two members of the replica set you are attempting to synchronize have the same ReplicaID.
        MsgBox "You are trying to sync the design master to itself, this wont work.", vbCritical
        
    Case Else
        MsgBox Err.Number & vbCrLf & vbCrLf & Err.Description, vbCritical, Err.Source
        
End Select

End Sub
will syncronise a replicated database to the design master, to sync the design master to replica is basically the same but switch CurrentProject.FullName to the full name and path of the design master.

HTH, Jamie
FAQ219-2884
[deejay]
 
Hi, also there is a synchronize method for the currentdb object (CurrentDb.Synchronize pathname,exchangetype) you could try that?

HTH, Jamie
FAQ219-2884
[deejay]
 
Wow....I was hoping it was going to be something a lot easier than that! I'll give that a try....but I can tell you that looks a little out of my scoope! Thanks!

JAM
 
Hi JAM,

try the
currentdb.synchronize "\\designmasterpath\andname.mdb", jrSyncTypeImpExp,jrSyncModeDirect
(look up synchronise in help) as this is far simpler, all you need is this one line - I just wanted more control and forgot about this till after I'd posted...

HTH, Jamie
FAQ219-2884
[deejay]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top