• Can’t populate partial replicat

    • This topic has 5 replies, 3 voices, and was last updated 24 years ago.
    Author
    Topic
    #354925

    Trying to make my first Acc97 partial replica using VBA code. Used some code from a MS article (??), and modified it for my purposes. Can’t open the partial replica database in Exclusive mode using VBA even though I can open it Exclusive with the Access user interface. If I open the file non-exclusive, it fails in the db.populatepartial method.

    Any help appreciated.

    ************************
    Option Compare Database
    Option Explicit

    Const sDBPARTIALName As String = “I:systemcorpdataAdmanBE.WDCorp.mdb”
    Const sDBMASTER As String = “H:COMPUTERAdMANReplicateAdmanBE.DesignMaster.mdb”

    Public Function CreatePartialReplica()
    Dim db As Database
    Set db = OpenDatabase(sDBMASTER)

    db.MakeReplica sDBPARTIALName, “WD version of only CORPORATE data”, dbRepMakePartial
    db.Close
    End Function

    Public Function CreatePartialFilter()
    Dim db As Database
    Dim rs As Recordset

    Dim tdf As TableDef
    Dim rel As Relation

    Set db = OpenDatabase(sDBPARTIALName, True)
    Set rs = CurrentDb.OpenRecordset(“dLkupPartiallyReplicatedTableNames”)

    While Not rs.EOF
    Set tdf = db.TableDefs(rs!tablename)
    tdf.ReplicaFilter = “RecordstatusID = 1 OR RecordstatusID = 2”

    For Each rel In db.Relations
    If rel.Table = rs!tablename Or rel.ForeignTable = rs!tablename Then
    rel.PartialReplica = True
    End If
    Next rel

    rs.MoveNext
    Wend

    db.Close
    MsgBox “done”
    End Function

    Public Function PopulatePartial()
    Dim db As Database

    Set db = OpenDatabase(sDBPARTIALName, True)
    db.PopulatePartial sDBMASTER
    db.Close

    End Function

    Viewing 0 reply threads
    Author
    Replies
    • #522532

      Hi,

      Before I look at this any further, I am curious about the following syntax: AdmanBE.WDCorp.mdb

      What is the purpose/significance of the first period? frown

      • #522554

        No real significance — I had just gotten into the habit of differentiating the purpose of the db with an additional part of the name. This particular filename means to be:
        “ADMan – BackEnd – purpose is WestDivisional Corporate”
        Maybe I should try it without the periods — stranger things have happened…

        • #522605

          Get out of the habit of using periods in file names immediately! Periods have specific meaning to the operating system, and it is a very bad idea to preempt that meaning. It will work OK most of the time and bite you badly when you least expect it.

      • #522572

        In the line:
        Set db = OpenDatabase(sDBPARTIALName, True)
        Set rs = CurrentDb.OpenRecordset(“dLkupPartiallyReplicatedTableNames”)

        What userID will be used for the new database? Will it be the default Admin user, or will it be the user of the currently-running Access session? I am currently logged in as Programmer, which is the owner of the database. The Admin user has very restricted permissions.

        • #522606

          Unless you pass the specific UserID and password, you will be logged into the new database object as Admin.

    Viewing 0 reply threads
    Reply To: Can’t populate partial replicat

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: