help with button code (1 Viewer)

dgb

Registered User.
Local time
Today, 18:58
Joined
Apr 11, 2002
Messages
12
Microsoft help emailed me with the following message. I am trying to create a button that will replicate without closing the db first. and another button to sync without closing. Because supposidly you cannot replicate when the db closes in the runtime version of access. So she sent me this code to put in the click procedure. But i am not sure how to do this. i tried and all i get is errors. Can anyone give me more step by step instructions. I really appreciate it. Dan...

Hi Dan,

Synchronizing cannot be done from within a runtime application because the database must close and reopen to complete the process. The runtime application cannot close and reopen itself.
To create a replica, the database must synchronize when creating the replica and for the same reason above, this cannot be done.
We can use JRO code (Jet Replication Objects) to get around this because the database does not have to be closed.
What you will have to do is create a command button on a form for each task - A button to synchronize, and a button to Create a replica.
Add a reference to JRO under Tools References in the VBE. (Visual Basic Editor)
Create a form with two buttons.
Behind the button to Synchronize, copy this code.


Dim repMaster As New JRO.Replica
repMaster.ActiveConnection = currentproject.connection
‘ Synchronize the values.
repMaster.Synchronize “C:\Path to replica”, jrSyncTypeImpExp, jrSyncModeDirect
this code should appear above End Sub
Behind the button to Create a Replica, copy this code
Dim x As New JRO.Replica
Dim y As String

y = InputBox(“Enter path for replica”)
x.ActiveConnection = CurrentProject.Connection
x.CreateReplica y, “My Full Replica1”, jrRepTypeFull, jrRepVisibilityGlobal

this code should appear above End Sub
 

Travis

Registered User.
Local time
Today, 10:58
Joined
Dec 17, 1999
Messages
1,332
Did you

"Add a reference to JRO under Tools References in the VBE. (Visual Basic Editor)"

Without the reference the code does not know what you are doing.
 

dgb

Registered User.
Local time
Today, 18:58
Joined
Apr 11, 2002
Messages
12
Thanks Travis, i was able to figure it out. Dan. And you were right, that is what i needed to do. Thanks again.
 

Users who are viewing this thread

Top Bottom