By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,025 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Replication via code

P: n/a
Hi

I have a front-end/back-end access app. I have created a replication set
between the backend on a server an the backend on a laptop. My question is;
How can I cause the synchronisation to happen via code? Basically I need to
give the user an option to press a button (or menu option) on the laptop
when the laptop is connected to the server/network for synchronisation to
happen.

Thanks

Regards
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Wed, 8 Jun 2005 13:33:37 +0100, "John" <Jo**@nospam.infovis.co.uk>
wrote:

Look up the Synchronize method in the help file.
-Tom.

Hi

I have a front-end/back-end access app. I have created a replication set
between the backend on a server an the backend on a laptop. My question is;
How can I cause the synchronisation to happen via code? Basically I need to
give the user an option to press a button (or menu option) on the laptop
when the laptop is connected to the server/network for synchronisation to
happen.

Thanks

Regards


Nov 13 '05 #2

P: n/a
Can't find it. Search in both access 2000 help and access 2000 visual basic
help. Can you let me know the syntax?

Thanks

Regards
"Tom van Stiphout" <no*************@cox.net> wrote in message
news:fk********************************@4ax.com...
On Wed, 8 Jun 2005 13:33:37 +0100, "John" <Jo**@nospam.infovis.co.uk>
wrote:

Look up the Synchronize method in the help file.
-Tom.

Hi

I have a front-end/back-end access app. I have created a replication set
between the backend on a server an the backend on a laptop. My question
is;
How can I cause the synchronisation to happen via code? Basically I need
to
give the user an option to press a button (or menu option) on the laptop
when the laptop is connected to the server/network for synchronisation to
happen.

Thanks

Regards

Nov 13 '05 #3

P: n/a
Synchronizes two replicas. (Microsoft Jet databases only).

Syntax

database.Synchronize pathname, exchange

The Synchronize method syntax has the following parts.

Part Description
database An object variable that represents a Database object that is
a replica.
pathname A String that contains the path to the target replica with
which database will be synchronized. The .mdb file name extension is
optional.
exchange Optional. A constant indicating which direction to
synchronize changes between the two databases, as specified in Settings.
Settings

You can use the following constants in the exchange argument. You can use
one of the first three constants with or without the fourth constant.

Constant Description
dbRepExportChanges Sends changes from database to pathname.
dbRepImportChanges Sends changes from pathname to database.
dbRepImpExpChanges (Default) Sends changes from database to pathname,
and vice-versa, also known as bidirectional exchange.
dbRepSyncInternet Exchanges data between files connected by an
Internet pathway.
Remarks

You use Synchronize to exchange data and design changes between two
databases. Design changes always happen first. Both databases must be at the
same design level before they can exchange data. For example, an exchange of
type dbRepExportChanges might cause design changes at a replica even though
data changes flow only from the database to pathname.

The replica identified in pathname must be part of the same replica set. If
both replicas have the same ReplicaID property setting or are Design Masters
for two different replica sets, the synchronization fails.

When you synchronize two replicas over the Internet, you must use the
dbRepSyncInternet constant. In this case, you specify a Uniform Resource
Locator (URL) address for the pathname argument instead of specifying a
local area network path.

Note You can't synchronize partial replicas with other partial replicas. See
the PopulatePartial method for more information.

Synchronization over the Internet requires the Replication Manager, which is
only available in the Microsoft Office 97, Developer Edition.

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:42*********************@news-text.dial.pipex.com...
Can't find it. Search in both access 2000 help and access 2000 visual basic help. Can you let me know the syntax?

Thanks

Regards
"Tom van Stiphout" <no*************@cox.net> wrote in message
news:fk********************************@4ax.com...
On Wed, 8 Jun 2005 13:33:37 +0100, "John" <Jo**@nospam.infovis.co.uk>
wrote:

Look up the Synchronize method in the help file.
-Tom.

Hi

I have a front-end/back-end access app. I have created a replication set
between the backend on a server an the backend on a laptop. My question
is;
How can I cause the synchronisation to happen via code? Basically I need
to
give the user an option to press a button (or menu option) on the laptop
when the laptop is connected to the server/network for synchronisation tohappen.

Thanks

Regards


Nov 13 '05 #4

P: n/a
"John" <Jo**@nospam.infovis.co.uk> wrote in
news:#q**************@TK2MSFTNGP09.phx.gbl:
I have a front-end/back-end access app. I have created a
replication set between the backend on a server an the backend on
a laptop. My question is; How can I cause the synchronisation to
happen via code? Basically I need to give the user an option to
press a button (or menu option) on the laptop when the laptop is
connected to the server/network for synchronisation to happen.


In form design, drop a command button on your form. If the wizard
pops up, dismiss it.

Name your command button (something like "cmdSynchronize").

In the command button's properties, on the EVENTS tab, choose
OnClick, and click the ... button. Choose CODE (not Macro).

For the code, you'll need something like this:

Dim dbSynch As DAO.Database
Dim strLocal As String
Dim strRemote As String

strLocal = "[path/name of the local laptop replica]"
strRemote = "[path/name of the server replica]"
Set dbSynch = DBEngine(0).OpenDatabase(strLocal)
dbSynch.Synchronize strRemote

dbSynch.Close
Set dbSynch = Nothing

Now, that's sufficient for doing a direct synch when connected to
the LAN. You wouldn't want to use this connected over dialup.

Also, it does nothing to check for conflicts (or errors, if you're
using A97). But those can be checked for and resolved manually by
opening the data files in Access.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #5

P: n/a
What happens when there is a conflict? Does the command come up with a
conflict resolution dialog or raises an error?

Thanks

Regards

"Ian Davies" <ia***************@virgin.net> wrote in message
news:l5******************@newsfe1-gui.ntli.net...
Synchronizes two replicas. (Microsoft Jet databases only).

Syntax

database.Synchronize pathname, exchange

The Synchronize method syntax has the following parts.

Part Description
database An object variable that represents a Database object that is
a replica.
pathname A String that contains the path to the target replica with
which database will be synchronized. The .mdb file name extension is
optional.
exchange Optional. A constant indicating which direction to
synchronize changes between the two databases, as specified in Settings.
Settings

You can use the following constants in the exchange argument. You can use
one of the first three constants with or without the fourth constant.

Constant Description
dbRepExportChanges Sends changes from database to pathname.
dbRepImportChanges Sends changes from pathname to database.
dbRepImpExpChanges (Default) Sends changes from database to pathname,
and vice-versa, also known as bidirectional exchange.
dbRepSyncInternet Exchanges data between files connected by an
Internet pathway.
Remarks

You use Synchronize to exchange data and design changes between two
databases. Design changes always happen first. Both databases must be at
the
same design level before they can exchange data. For example, an exchange
of
type dbRepExportChanges might cause design changes at a replica even
though
data changes flow only from the database to pathname.

The replica identified in pathname must be part of the same replica set.
If
both replicas have the same ReplicaID property setting or are Design
Masters
for two different replica sets, the synchronization fails.

When you synchronize two replicas over the Internet, you must use the
dbRepSyncInternet constant. In this case, you specify a Uniform Resource
Locator (URL) address for the pathname argument instead of specifying a
local area network path.

Note You can't synchronize partial replicas with other partial replicas.
See
the PopulatePartial method for more information.

Synchronization over the Internet requires the Replication Manager, which
is
only available in the Microsoft Office 97, Developer Edition.

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:42*********************@news-text.dial.pipex.com...
Can't find it. Search in both access 2000 help and access 2000 visual

basic
help. Can you let me know the syntax?

Thanks

Regards
"Tom van Stiphout" <no*************@cox.net> wrote in message
news:fk********************************@4ax.com...
> On Wed, 8 Jun 2005 13:33:37 +0100, "John" <Jo**@nospam.infovis.co.uk>
> wrote:
>
> Look up the Synchronize method in the help file.
> -Tom.
>
>
>>Hi
>>
>>I have a front-end/back-end access app. I have created a replication
>>set
>>between the backend on a server an the backend on a laptop. My question
>>is;
>>How can I cause the synchronisation to happen via code? Basically I
>>need
>>to
>>give the user an option to press a button (or menu option) on the
>>laptop
>>when the laptop is connected to the server/network for synchronisation to >>happen.
>>
>>Thanks
>>
>>Regards
>>
>



Nov 13 '05 #6

P: n/a
"John" <Jo**@nospam.infovis.co.uk> wrote in
news:42*********************@news-text.dial.pipex.com:
What happens when there is a conflict? Does the command come up
with a conflict resolution dialog or raises an error?


No, it doesn't. You must check for conflicts manually, or use code
to check for conflicts.

If there are conflicts, there will be new conflict tables for each
table having conflicts. If the original table was named tblPerson,
the conflict table will be called tblPerson_Conflicts (or maybe it's
tblPerson_Conflict -- I can't remember).

To check for conflicts, do this:

Dim dbLocalReplica As DAO.Database
Dim strLocal As String
Dim tdf As DAO.TableDef
Dim strTableName As String
Dim strConflictTables As String
Dim strMsg As String

strLocal = "[path/name of local replica]"
Set dbLocalReplica = DBEngine(0).OpenDatabase(strLocal)
For Each tdf In dbLocalReplica.TableDefs
strTableName = tdf.Name
If Right(strTableName, 10) = "_Conflicts" Then
strConflictTables = strConflictTables & ", " _
& Left(strTableName, Len(strTableName) - 10)
End If
Next tdf
Set tdf = Nothing
dbLocalReplica.Close
Set dbLocalReplica = Nothing

If Len(strConflictTables) <> 0 Then
strMsg = "There are conflicts in these tables:"
strMsg = strMsg & vbCrLf & " " & vbCrLf
strMsg = strMsg & Mid(strConflictTables, 3)
MsgBox strMsg, vbExclamation, "Conflicts Found!"
End If

You could then open the replica in Access for the end user and the
built-in error dialog for conflicts/errors would pop up.

Or, you could design your own conflict resolver, but that's quite
complex. There are instructions for how to do this in the Access
Developers Handbook, but note that the A2K version uses JRO, which I
simply wouldn't recommend.

The problem with using the A97 version, though, is that replication
was significantly changed from Jet 3.5 to Jet 4.0, with the
elimination of standalone replication errors (data errors and schema
errors), or, more correctly, the treating of replication errors as a
form of conflict.

Just reviewing the code there, however, I see some things I never
knew before, that the MSysSideTables table includes a list of
conflict tables, so, instead of the code above, you could do this:

Dim rs As DAO.Recordset
Dim strSQL As String
Dim strTableList As String

If dbLocalReplica.TableDefs("MSysSideTable").RecordCo unt <> 0 Then
strSQL = "SELECT MSysTableGuids.TableName, "
strSQL = strSQL & "MSysSideTables.SideTable AS ConflictTable "
strSQL = strSQL & "FROM MSysSideTables, MSysTableGuids "
strSQL = strSQL & "WHERE MSysTableGuids.s_GUID=[TableGuid] "
strSQL = strSQL & "ORDER BY MSysTableGuids.TableName;"
Set rs = dbLocalReplica.OpenRecordset(strSQL)
rs.MoveFirst
Do While Not rs.EOF
strTableList = strTableList & vbCrLf & rs!TableName
strTableList = strTableList & ": " & rs!ConflictTable
rs.MoveNext
Loop
End If
strMsg = "There are conflicts in these tables:"
strMsg = strMsg & vbCrLf & " " & vbCrLf
strMsg = strMsg & Mid(strTableList , 3)
MsgBox strMsg, vbExclamation, "Conflicts Found!"

I'm not sure that's easier! I do believe that the test to see if
there are any conflicts will definitely be faster, though, as it
doesn't require a loop through the TableDefs collection.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.