How do I open the "create replica" area using VBA code

Hi experts,

I would like to create a button on my form that does exactly the same thing as clicking Tools>Replication>Create Replica.  Is this possible? If so, please could somebody advise me how I do this.  

Thank you.
Terry
TerenceHewettAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
private sub makeReplica()
dim origDb as string, newDb as string
origDb="c:\backend_be.mdb"
newDb="c:\replicated\replica of backend_be.mdb"

'call the function to create new replica

MakeAdditionalReplica(origDb,newDb,1)

end sub
0
 
Rey Obrero (Capricorn1)Commented:
0
 
TerenceHewettAuthor Commented:
Many thanks for the link to the thread. I am still having difficulty in making the function work.  I believe that I first have to create a "replicable master" and then use the code in your thread to create the replica.  My original backend that I am trying to replicate is in "c:\backend_be.mdb" and I am trying to place the replicated database in "c:\replicated\replica of backend_be.mdb".  I know it should be easy from here but I am finding it difficult to substitute my filenames and paths etc. into the code.  I am having difficulty defining and substituting the terms "strReplicableDB" and "strNewReplica".  I do not have any options.  Are you able to provide any further assistance?

Function MakeAdditionalReplica(strReplicableDB As _
   String, strNewReplica As String, intOptions As _
   Integer) As Integer

   Dim dbsTemp As Database
   On Error GoTo ErrorHandler

   Set dbsTemp = OpenDatabase(strReplicableDB)

   ' If no options are passed to
   ' MakeAdditionalReplica, omit the
   ' options argument, which defaults to
   ' a full, read/write replica. Otherwise,
   ' use the value of intOptions.

   If intOptions = 0 Then
      dbsTemp.MakeReplica strNewReplica, _
         "Replica of " & strReplicableDB
   Else
      dbsTemp.MakeReplica strNewReplica, _
         "Replica of " & strReplicableDB, _
         intOptions
   End If

   dbsTemp.Close

ErrorHandler:
   Select Case Err
      Case 0:
         MakeAdditionalReplica = 0
         Exit Function
      Case Else:
         MsgBox "Error " & Err & " : " & Error
         MakeAdditionalReplica = Err
         Exit Function
   End Select

End Function


Many thanks for your help.

Regards,
Terry
0
 
TerenceHewettAuthor Commented:
Hi Cap,

Thank you for your post and patience. Apologies for the delay in responding.  The code worked perfectly.  As usual, A+++++ result.

Terry
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.