[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 366
  • Last Modified:

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
0
TerenceHewett
Asked:
TerenceHewett
  • 2
  • 2
1 Solution
 
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
 
Rey Obrero (Capricorn1)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
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now