?
Solved

Synchronizing MS Access tables

Posted on 2004-07-31
3
Medium Priority
?
519 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

800 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