Replication and synchronization

HEllo Experts,

I would like to know if I can replicate and synchronize auomatically with acommand button on database form.

I am using access 2003 database ,how shall i code for this, I have created an command button and would like to put code for the above.

please need help from u,right nowas its urgent , if u can.

thanx
Rachel
racheleeAsked:
Who is Participating?
 
rockiroadsCommented:
example on how to setup

1. create your master db, has all your forms, queries, tables etc etc etc in it
2. on this form, create a button, either on a new form or an existing form where u want the synchronisation to take place
3. decide on a location for this master db (this is simple way, fancy way would be to prompt for the location)
4. this is the code to put in

    Dim dbMaster As DAO.Database
   
    'Open the Master database
    Set dbMaster = opendatabase("C:\EE\Replication\Master.mdb")
   
    'This line sends changes made in each replica to the other i.e. Master to Replica and vice versa
    dbMaster.Synchronize CurrentProject.Path & "\" & CurrentProject.Name, dbRepImpExpChanges
   
    dbMaster.Close
   
    MsgBox "Done"


5. Ensure u have Microsoft DAO object library set

Thats your master complete,

Now select Tools/Replication/Create Replica

this now creates a replicated database


Now try a test, add some data to master, add different data to same table but in replicate

now in replica, hit this button, it will then start synching

now check the data in both databases, u should find it matches

0
 
t_itaniumCommented:
0
 
racheleeAuthor Commented:
here its given about how shall i make it programmically, but i am new to database , will u please let me know how shall i write it in code?

thnx
Rachel
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
racheleeAuthor Commented:
I need replikation and synchronisation to be done by just one command button on the form

thnx again#Rachel
0
 
t_itaniumCommented:
0
 
racheleeAuthor Commented:
well, thanx a lot, i will try and get back to u soon

Rachel
0
 
racheleeAuthor Commented:
well, I did read all, but i dont know how to apply on my database,

will u please tell me how shall i code it , shall I start with replica and then synchronisation, and which code i have to write if my path is "H:\share\mean.mdb"

please tell me
0
 
t_itaniumCommented:
did you see the codes in
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/jrorep.asp
??

in a form in access create a button right click it and chose build event..then write the code of creating the replica ...and then to syncronize..in the event...

ok..

cheers
0
 
racheleeAuthor Commented:
when i open the built event  I can see the below codes writeen ,

1)is that code correct?
2)where shall i write my replication and synchronization code?


thank you
0
 
t_itaniumCommented:
no you can can delete the built in event code of that button and write your own code inside in this case you write the rep and sync code in the event of the button
0
 
racheleeAuthor Commented:
which replication codes shall i follow, the below one is for sync is that right line?.
if this is not correct code , what changes shall i make in this


Private Sub Befehl25_Click()
On Error GoTo Err_Befehl25_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Project"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
   
    CurrentDb.Synchronize "H:\Test.mdb", dbRepImpExpChanges

Exit_Befehl25_Click:
    Exit Sub

Err_Befehl25_Click:
    MsgBox Err.Description
    Resume Exit_Befehl25_Click
   
End Sub

please let me know now...if uhave time..I want to finish it by today.
0
 
t_itaniumCommented:
it seems fine to me..  but i am not familiar with the exact syntax..especially  On Error..but else it is good..
0
 
racheleeAuthor Commented:
no its giving me error like ,
type of synchronization is not valid???

how abt that?

regards
Rachel
0
 
t_itaniumCommented:
try to read this and follow the way the code did.....

cheeeers

Synchronizing Data
Synchronizing two replicas involves exchanging data and design changes. Synchronization can be bidirectional (that is, changes in each replica are propagated to the other), or it can occur in a single direction.

Microsoft Jet also supports two styles of synchronization:

Direct synchronization is when the synchronization process has a direct connection to both replicas and is able to open both replicas simultaneously. Updates are immediately read and written to both replicas.
Indirect synchronization is when there is no direct connection to the remote replica. Instead the local replica collects its updates into a "message" file, which is written to a predetermined location, referred to as a dropbox folder. At some later time, the remote replica looks at its dropbox folder, reads the message file and applies the updates. Indirect synchronization can either send the message file over the file system or the Internet or an intranet.
Direct synchronization is the default method used by Microsoft Jet replication and is ideal when the replicas are on a local area network (LAN). Direct synchronization is usually a poor choice when replicas are physically dispersed and synchronization is over a wide area network (WAN) or dial-up connection.

Indirect synchronization is almost always the better choice for synchronizing dispersed replicas over a WAN or dial-up connection. With indirect synchronization, you never open the remote replica over a potentially unreliable communications link. Instead synchronization occurs in two phases, with each phase being controlled by a process running locally to each replica. Since you are never opening a replica remotely, indirect synchronization is both fast and robust.

The following code demonstrates how to synchronize changes between two replicas. The first example shows how to do a direct, two-way synchronization.

Sub TwoWayDirectSync(strReplica1 As String, _
                     strReplica2 As String)
   Dim repReplica  As New JRO.Replica

   repReplica.ActiveConnection = strReplica1

   ' Sends changes made in each replica to the other.
   repReplica.Synchronize strReplica2, jrSyncTypeImpExp, _
      jrSyncModeDirect

   Set repReplica= Nothing
End Sub

For example, to synchronize the Design Master of the Northwind database with a member of its replica set, you would use the following line of code:

TwoWayDirectSync "c:\NorthwindDM.mdb", "c:\NwindReplica2.mdb"

The following example shows how to do a two-way synchronization over the Internet.

Note   To configure an Internet or intranet server so that you can synchronize replicas, you must install Replication Manager, which is available with Microsoft Office 2000 Developer. For more information about installing and running Replication Manager, see Microsoft Office 2000 Developer Help. For the latest information about configuring and running Replication Manager, search the Office Developer product section of the Microsoft Support Online Web site (http://support.microsoft.com/support/default.asp) for the keyword phrase "Replication Manager."
Sub InternetSync(strLocalReplicaPath As String, _
                 strServerReplicaURL As String)
   Dim repLocalReplica  As New JRO.Replica

   repLocalReplica.ActiveConnection = strLocalReplicaPath

   ' Synchronize the local replica with the replica on
   ' the Internet server.
   repLocalReplica.Synchronize strServerReplicaURL, jrSyncTypeImpExp, _
      jrSyncModeInternet

   Set repLocalReplica = Nothing
End Sub

For example, to synchronize the OrderEntry.mdb replica on your local machine with the Orders.mdb replica on the Internet server, you would use the following line of code:

InternetSync "c:\Data\OrderEntry.mdb", "www.mycompany.myserver.com/files/Orders.mdb"

The JRO and DAO code for performing a two-way, direct synchronization between two replicas is similar. However, note that the JRO Synchronize method has an additional SyncMode argument that specifies whether the synchronization is direct (jrSyncModeDirect) or indirect (jrSyncModeIndirect). For functionality equivalent to DAO, you must specify jrSyncModeDirect when calling the Synchronize method. If you omit the SyncMode argument, the synchronization will be performed indirectly. The ability to programmatically perform indirect synchronizations is a new feature in JRO, designed to increase performance when you are synchronizing over a WAN. For more information about performing indirect synchronizations, see "Indirect Synchronization" later in this document.

The following table shows the mapping between the constants taken by the DAO Exchange argument of the Synchronize method and the constants taken by the JRO SyncType and SyncMode arguments.

DAO JRO
Exchange:=dbRepExportChanges SyncType:=jrSyncTypeExport
Exchange:=dbRepImportChanges SyncType:=jrSyncTypeImport
Exchange:=dbRepImExpChanges SyncType:=jrSyncTypeImpExp
Exchange:=dbRepSyncInternet SyncMode:=jrSyncModeInternet
0
 
racheleeAuthor Commented:
Thnx ,

Actually i have been seeing it since long time, but could not use in codes, thta did not work.

will u please tell me how shall i put it in code, if u have done it before??

thnx
regrards
Rachel
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.