Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Replication / June 2006

Tip: Looking for answers? Try searching our database.

Code to initiate sync from replica

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
HGil - 20 Jun 2006 15:46 GMT
I'm in the process of developing an application where my users will
take a replicated db out of the office on a laptop and, upon their
return, sync to the master db on the company network.

I'm trying to use the code below to initate the sync process from the
replica (after connecting to the network the users would click a button
in their laptop-based replicated db and it would sync with the master).

The code runs smoothly (no errors), but nothing is transferred ineither
direction during the sync.  If I manually sync the db's from the
master, using Tools-->Replication-->Syncronize Now menu command,
everything syncs correctly and data is transferred.  My code seems to
be goofed....

CODE:

Private Sub SynchDb_Click()
   Dim dbTestCxn           As DAO.Database
   Dim dbSynch             As DAO.Database
   Dim strTestDbPath       As String
   Dim strSynchFieldDb     As String
   Dim strSynchNetworkDb   As String

   'test network connection to a known db
   strTestDbPath =
"\\server1\user\GIS\applications\InspectionsDb\NetworkConnectionTest.mdb"
   'standard location of inspection db on tablet pc - currently on
network for testing
   strSynchFieldDb =
"\\server1\user\ErosionAndSedimentControl\ConstructionSiteESC\Erosion
Control Access Database\Database\InspectionRep.mdb"
   'standard network location for master inspections db
   strSynchNetworkDb = "\\server1\User\HDG\db\Inspection.mdb"

   On Error Resume Next
   Set dbTestCxn = DBEngine.OpenDatabase(strTestDbPath)
   CheckLinks = (Err.Number = 0)   'If no error there is a network
conneciton, return True.
   dbTestCxn.Close

   If CheckLinks = True Then
       Set dbSynch = DBEngine.OpenDatabase(strSynchFieldDb)
       dbSynch.Synchronize strSynchNetworkDb, dbRepImpExpChanges
       dbSynch.Close
       Set dbSynch = Nothing
       Set dbTestCxn = Nothing
       MsgBox ("Done.  The databases have been successfully updated.")
   Else
      MsgBox ("You are not connected to the Company network.  You
cannot transfer data at this time.")
       Set dbSynch = Nothing
       Set dbTestCxn = Nothing
   End If

End Sub

QUESTIONS:
1) is there some issue with my testing the master and resplica both on
the network - not having the replica actually on a laptop?  I wouldn't
think this would be the case, but I'm stumped.

2) do I need to physically close the replica db through code before the
sync will work (and then reopen after the sync)?

Any suggestions would be welcome.  Thanks.

HGil
David W. Fenton - 21 Jun 2006 01:28 GMT
> I'm in the process of developing an application where my users
> will take a replicated db out of the office on a laptop and, upon
[quoted text clipped - 10 lines]
> command, everything syncs correctly and data is transferred.  My
> code seems to be goofed....

[]

>     'test network connection to a known db
>     strTestDbPath =
[quoted text clipped - 8 lines]
>     'standard network location for master inspections db
>     strSynchNetworkDb = "\\server1\User\HDG\db\Inspection.mdb"

...

>  Set dbTestCxn = DBEngine.OpenDatabase(strTestDbPath)

...

>   dbSynch.Synchronize strSynchNetworkDb, dbRepImpExpChanges

The replicas you are synching are both on the same machine, because
the names begin with "\\server1".

If you want to synch between the laptop and the server, one of the
two, either the "Set db =" or the strTestDbPath, have to be on the
laptop, usually called with a local path (C:\ etc.).

Signature

David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/

HGil - 21 Jun 2006 14:07 GMT
SNIP

> >     'test network connection to a known db
> >     strTestDbPath =
[quoted text clipped - 23 lines]
> two, either the "Set db =" or the strTestDbPath, have to be on the
> laptop, usually called with a local path (C:\ etc.).

Thanks for the reply David.

I know that eventually the replicas will be on laptops.  I was just
testing the code on the network.  Why would being on the same machine
matter to the sync process?

Anyway...even if I create a replica on my local machine and have the
code reference a local C:\ path, I get the same results (or lack of
results).

When I manually sync from the design master Access asks me to close the
db before it will sync.  Is this somehting I need to do in the code as
well?  Also, I don't have the option to manually sync the dbs from
within the replica.  Can I not initiate a sync from the replica either
manually or by code?  I wouln't think that this is the case, but I
don't know anymore.

Thanks again for any insights,
HGil
David W. Fenton - 22 Jun 2006 00:50 GMT
> SNIP
>
[quoted text clipped - 31 lines]
> just testing the code on the network.  Why would being on the same
> machine matter to the sync process?

Well, OK. I assumed you were synching a laptop replica with a server
replica, but any two replicas should work.

> Anyway...even if I create a replica on my local machine and have
> the code reference a local C:\ path, I get the same results (or
> lack of results).

I'm stumped.

> When I manually sync from the design master Access asks me to
> close the db before it will sync.  Is this somehting I need to do
> in the code as well?  Also, I don't have the option to manually
> sync the dbs from within the replica.  Can I not initiate a sync
> from the replica either manually or by code?  I wouln't think that
> this is the case, but I don't know anymore.

Not sure why you'd have to close the DM before synching.

I'm also not sure why a direct DAO synch wouldn't work, as it's
exactly the same method that the Access UI implements behind the
scenes.

Keep in mind that I'm assuming certain things:

1. you have an MDB that is your front end, from which you're
synching the back end that the front end's linked tables are linked
with to a different replica.

2. you need to make your database variable point to either the back
end that your front end uses, or the partner replica you want to
synch with, and the other replica will be, well, the other replica
you want to synch with.

Assuming that your front end is linked to
\\server1\user\GIS\applications\InspectionsDb\NetworkConnectionTest.m
db, and you want to synch with \\server1\User\HDG\db\Inspection.mdb,
then your code really should be working.

I suspect that something is not as you assume it to be, though.

Signature

David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/

David W. Fenton - 21 Jun 2006 13:35 GMT
Signature

David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/

jacksonmacd - 21 Jun 2006 14:16 GMT
You don't mention it explicitly, but is your application split into
frontend and backend components? Replication is intended for backend
(tables) only.

>I'm in the process of developing an application where my users will
>take a replicated db out of the office on a laptop and, upon their
[quoted text clipped - 63 lines]
>
>HGil

--
jackmacMACdonald@telusTELUS.net
remove uppercase letters for true email
http://www.geocities.com/jacksonmacd/ for info on MS Access security
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.