Solved

Synchronizing MS Access tables

Posted on 2004-07-31
3
514 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

726 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