Solved

Synchronizing MS Access tables

Posted on 2004-07-31
3
510 Views
Last Modified: 2008-02-01
Hi.

I urgently need some expert help.  I have an application where I need a mechanism to synchronize the local tables with the tables that are deployed on the Web Server (a MS Access database deployed on the Web Server).

How can I do this?  Do I need to write a program using other languages to build this synchronization module?

Please help!!!

THanks very much.
0
Comment
Question by:winpiglet
3 Comments
 

Accepted Solution

by:
berq earned 250 total points
ID: 11691030
ok try use this code
create a new database name  autosync
create a module name 'libReplication'
then copy this code

Option Compare Database
Option Explicit
Dim intSysCounter As Long
Dim varReturn As Variant


Function SyncMultipleDBs()
Dim strReplicaList(5) As String  'Up to 5 Replicas
Dim strMasterDB As String

'set the number of replica(s)
Const NoofReplicas = 5
     
    intSysCounter = 1
    varReturn = SysCmd(acSysCmdInitMeter, "Syncronising Databases", NoofReplicas)
    strMasterDB = "C:\MSACCESS\FullReplica\DB_FR.mdb" 'location of the master_db
    strReplicaList(0) = "C:\MSACCESS\PartialReplicas\DB_FR.mdb" 'Location partial replica 1
    strReplicaList(1) = "C:\MSACCESS\PartialReplicas\DB_FR.mdb" 'Location partial replica 2
    strReplicaList(2) = "C:\MSACCESS\PartialReplicas\DB_FR.mdb" 'Location partial replica 3
    strReplicaList(3) = "C:\MSACCESS\PartialReplicas\DB_FR.mdb" 'Location partial replica 4
    strReplicaList(4) = "C:\MSACCESS\PartialReplicas\DB_FR.mdb" 'Location partial replica 5


    SyncALL strMasterDB, strReplicaList()
    varReturn = SysCmd(acSysCmdRemoveMeter)
End Function


Private Sub SyncOneWay(strFromDB As String, strToDB As String)
'Required Refence: Microsoft Jet and Replication Object
'Requires Network Connection to be already establised
Dim rpl As New JRO.Replica
    On Error GoTo 0
   
    rpl.ActiveConnection = strFromDB
    rpl.Synchronize strToDB, jrSyncTypeExport, jrSyncModeDirect
    varReturn = SysCmd(acSysCmdUpdateMeter, intSysCounter)
    intSysCounter = intSysCounter + 1
    'Debug.Print intSysCounter - 1 & strFromDB & " -> " & strToDB
    Set rpl = Nothing
End Sub

Private Sub SyncALL(strMasterDB As String, arrReplicas() As String)
Dim appAccess As New Access.Application
Dim intX As Long
Dim intUB As Long
Dim intLB As Long
    intLB = LBound(arrReplicas())
       
'Sync All Replicas to Full Replica
    intX = intLB
    Do
        If Len(arrReplicas(intX)) = 0 Then Exit Do
        SyncOneWay arrReplicas(intX), strMasterDB
        'Debug.Print arrReplicas(intX) & " -> Master"
        intX = intX + 1
    Loop
   
'Open Databases to Resolve Conflicts
    'Debug.Print "Resolving Conflicts -> " & strMasterDB
    appAccess.OpenCurrentDatabase (strMasterDB)
    appAccess.CloseCurrentDatabase
   
    'Open Target Databases
    intX = intLB
    Do
        If Len(arrReplicas(intX)) = 0 Then Exit Do
        'Debug.Print "Resolving Conflicts -> " & arrReplicas(intX)
        appAccess.OpenCurrentDatabase (arrReplicas(intX))
        appAccess.CloseCurrentDatabase
        intX = intX + 1
    Loop
End Sub

then create a macro to run function/code SyncMultipleDBs ()
name the macro as autoexec
so it's done
when ever you want to synchronize just click the autsync.mdb
or if you want to make it automate just set on your schedule task when do you want to run the code
i hope this will help you

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now