Solved

Synchronizing MS Access tables

Posted on 2004-07-31
3
513 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final pā€¦

791 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