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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a customized synchronization routine?

Status
Not open for further replies.

IngoNiclas

Technical User
Jun 9, 2004
9
US
I use the replication manager (Office Developer) to indirectly synchronize replicas of an Access database. Now I'd like to set up a customized synchronization routine that automatically initiates synchronization after a user has worked with and closed his replica. Any ideas where I could find VBA code that is related to this?

Many thanks in advance!!!
 
Hi IngoNiclas,

I use a reference to Microsoft Jet and Replication Objects 2.x library (C:\Program Files\Common Files\System\ADO\msjro.dll), though this is just in plain old A2k.

I use a couple of scripts
Code:
Public Sub DirectSyncToMaster()
[COLOR=green]' sync my tables to design master tables[/color]
    On Error GoTo err_handler
    
    r.ActiveConnection = [highlight]GetMasterConnection[/highlight]
    [COLOR=green]' RaiseEvent evtMessage("sync to master database in progress")[/color]
    r.Synchronize CurrentProject.FullName, jrSyncTypeImpExp, jrSyncModeDirect
    [COLOR=green]' RaiseEvent evtMessage("sync to master database complete")[/color]

Exit Sub

err_handler:
    Select Case Err.Number
        Case -2147467259        [COLOR=green]'The two members of the replica set you are attempting to synchronize have the same ReplicaID.[/color]
            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
and...
Code:
Public Sub DirectSyncMaster()
[COLOR=green]' sync design master tables to my tables[/color green]
    On Error GoTo err_handler

    r.ActiveConnection = CurrentProject.FullName
    [COLOR=green]' RaiseEvent evtMessage("sync master database to me in progress")[/color]
    r.Synchronize [highlight]GetMasterConnection[/highlight], jrSyncTypeImpExp, jrSyncModeDirect
    [COLOR=green]' RaiseEvent evtMessage("sync master database to me complete")[/color]

Exit Sub

err_handler:
    Select Case Err.Number
        Case -2147467259        [COLOR=green]'The two members of the replica set you are attempting to synchronize have the same ReplicaID.[/color]
            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
You'll need to swap [highlight]GetMasterConnection[/highlight] for your design master connect string, this is a function that I haven't posted...

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

Part and Inventory Search

Sponsor

Back
Top