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

Posted on 2007-10-05
Last Modified: 2013-11-27
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.
Question by:TerenceHewett
    LVL 119

    Expert Comment

    by:Rey Obrero

    Author Comment

    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
          dbsTemp.MakeReplica strNewReplica, _
             "Replica of " & strReplicableDB, _
       End If


       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.

    LVL 119

    Accepted Solution

    private sub makeReplica()
    dim origDb as string, newDb as string
    newDb="c:\replicated\replica of backend_be.mdb"

    'call the function to create new replica


    end sub

    Author Comment

    Hi Cap,

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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now