Auto Syncing Replicas

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jzalar
    New Member
    • Sep 2008
    • 9

    Auto Syncing Replicas

    We are lucky and get to run an 11 year old version of Access (97). I have set up a master with 5 replicas. These are located on various network drives in our organization. Is there any macro/code I can use to have the master auto sync each of the replicas when opened? the Microsoft website sucks and didn't help me at all. I would love any advice or help.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32663

    #2
    Can you be clearer as to what, EXACTLY, you want to have happen.

    Comment

    • jzalar
      New Member
      • Sep 2008
      • 9

      #3
      Originally posted by NeoPa
      Can you be clearer as to what, EXACTLY, you want to have happen.

      I would like to have a button on the master that automatically (without pop up and choices) syncs all of the replicas to the master.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32663

        #4
        I'm afraid if that's as clear as you can be then I'm unable to help.

        Comment

        • EManning
          New Member
          • Sep 2008
          • 13

          #5
          Look in Access Help for more info on this. I got in to this a bit a couple of years ago. Unless you're a programmer-extraordinare, it's a lot easier just to open the master, then do the Tools...Replica tion...Synchron ize Now.

          Comment

          • jzalar
            New Member
            • Sep 2008
            • 9

            #6
            Originally posted by NeoPa
            I'm afraid if that's as clear as you can be then I'm unable to help.

            Sorry about the confusion. I am looking for "Replicatio n Code" that I can put into a macro that will run the sync procedure out of sight of the user. The only thing I found was from the Microsoft website http://support.microsoft.com/kb/183710/en-us

            This is kind of what I need, but an actual working same so I can change the BD names and paths.

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #7
              !!!WARNING - this code exists only in the crevices of my mind! (LOL)! It has not been tested, since I do not have the means to, and I make no guarantee whatsoever as to how well it will work, or if it will even work at all. DO NOT USE THIS CODE ON THE LIVE MASTER AND REPLICAS! All that being said:
              1. Create a Table named tblReplicas, and within this Table create a single Field name [Replica_Path].
              2. Create 5 New Records in tblReplicas consisting of the 'Absolute' Network Path of the 5 Replicas, including the Database Name, such as:
                K:\Server4\Data bases\Replicas\ Replica_1.mdb
              3. Depending on how you want the Replication Process to perform, namely: MASTER ==> Replica, Replica ==> MASTER, MASTER <==> Replica, select 1 of the 3 With..End With code segments below.
                Code:
                'To Send changes from the MASTER to the Replica
                With rstReplicas
                --Do While Not .EOF
                ----MyDB.Synchronize ![Replica_Path], dbRepExportChanges
                ----.MoveNext       '.MoveNext
                --Loop
                End With
                ---
                'To have the MASTER receive changes from the Replica
                With rstReplicas
                --Do While Not .EOF
                ----MyDB.Synchronize ![Replica_Path], dbRepImportChanges
                ----.MoveNext
                --Loop
                End With
                ---
                'Changes from both the MASTER and Replica are exchanged
                '(Default - Bi-directional exchange)
                With rstReplicas
                --Do While Not .EOF
                ----MyDB.Synchronize ![Replica_Path], dbRepImpExpChanges
                ----.MoveNext
                --Loop
                End With
              4. Execute the following code from 'within the MASTER'.
                Code:
                Dim MyDB As DAO.Database
                Dim rstReplicas As DAO.Recordset
                ---
                Set MyDB = CurrentDb()
                ---
                Set rstReplicas = MyDB.OpenRecordset("tblReplicas", dbOpenForwardOnly)
                ---
                With rstReplicas
                --Do While Not .EOF
                ----'Use only [1] of 3 Synchronize Options listed below
                ----MyDB.Synchronize ![Replica_Path], dbRepExportChanges
                --- ------------------------ OR
                ----MyDB.Synchronize ![Replica_Path], dbRepImportChanges
                --- ------------------------ OR
                ----MyDB.Synchronize ![Replica_Path], dbRepImpExpChanges
                --- ------------------------ OR
                ----.MoveNext
                --Loop
                End With
                ---
                rstReplicas.Close
                Set rstReplicas = Nothing
              5. If you need any explanation on the code, either muself or one of the other Members will assist you.
              6. Say a Prayer, and let me know how you make out.

              Comment

              • jzalar
                New Member
                • Sep 2008
                • 9

                #8
                Will be trying it today. Thank you for the help.

                Comment

                • ADezii
                  Recognized Expert Expert
                  • Apr 2006
                  • 8834

                  #9
                  Originally posted by jzalar
                  Will be trying it today. Thank you for the help.
                  Kindly let me know the outcome, I'm interested myself.

                  Comment

                  • jzalar
                    New Member
                    • Sep 2008
                    • 9

                    #10
                    Originally posted by ADezii
                    Kindly let me know the outcome, I'm interested myself.
                    Sorry for the delay but I had to go to Ny for work and this wasn't part of that work. I tried it today but I can get it to run. I am not very good with VB so I keep getting complier error when debuging. This is what I used.

                    Code:
                     Dim MyDB As DAO.Database
                    Dim rstReplicas As DAO.Recordset
                    
                    Set MyDB = CurrentDb()
                    
                    Set rstReplicas = MyDB.OpenRecordset("tblReplicas", dbOpenForwardOnly)
                    
                    With rstReplicas
                    Do While Not .EOF
                        MyDB.Synchronize ![Replica_Path], dbRepImpExpChanges
                    .MoveNext
                    Loop
                    End With
                    
                    rstReplicas.Close
                    Set rstReplicas = Nothing
                    For some reason it does not like "Set MyDB" Not sure why.

                    Comment

                    • ADezii
                      Recognized Expert Expert
                      • Apr 2006
                      • 8834

                      #11
                      Originally posted by jzalar
                      Sorry for the delay but I had to go to Ny for work and this wasn't part of that work. I tried it today but I can get it to run. I am not very good with VB so I keep getting complier error when debuging. This is what I used.

                      Code:
                       Dim MyDB As DAO.Database
                      Dim rstReplicas As DAO.Recordset
                      
                      Set MyDB = CurrentDb()
                      
                      Set rstReplicas = MyDB.OpenRecordset("tblReplicas", dbOpenForwardOnly)
                      
                      With rstReplicas
                      Do While Not .EOF
                          MyDB.Synchronize ![Replica_Path], dbRepImpExpChanges
                      .MoveNext
                      Loop
                      End With
                      
                      rstReplicas.Close
                      Set rstReplicas = Nothing
                      For some reason it does not like "Set MyDB" Not sure why.
                      Make sure you have a Reference set to the Microsoft DAO X.X Object Library

                      Comment

                      • NeoPa
                        Recognized Expert Moderator MVP
                        • Oct 2006
                        • 32663

                        #12
                        Originally posted by jzalar
                        For some reason it does not like "Set MyDB" Not sure why.
                        Do you have a reference (Tools / References...) set to Microsoft DAO 3.6 Object Library (or similar version)?

                        PS. Possibly needed to refresh the page before replying - but I was doing some testing. I did find that this reference is not set automatically (Would have thought it would be).

                        Comment

                        Working...