Solved

Synchronizing MS Access tables

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
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…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 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