MakeReplica Method

Applies To

Database object.

Description

Makes a new replica from another database replica (Microsoft Jet workspaces only).

Syntax

database.MakeReplica replica, description, options

The MakeReplica method syntax has the following parts.

Part

Description

database

An object variable that represents an existing Database that is a replica.

replica

A String that is the path and file name of the new replica. If replica is an existing file name, then an error occurs.

description

A String that describes the replica that you are creating.

options

Optional. A constant or combination of constants that specifies characteristics of the replica you are creating, as specified in Settings.


Settings

You can use one or more of the following constants in the options argument.

Constant

Description

dbRepMakePartial

Creates a partial replica.

dbRepMakeReadOnly

Prevents users from modifying the replicable objects of the new replica; however, when you synchronize the new replica with another member of the replica set, design and data changes will be propagated to the new replica.


Remarks

A newly created partial replica will have all ReplicaFilter properties set to False, meaning that no data will be in the tables.

Example

This example uses the NextRecordset method to view the data from a compound SELECT query. The DefaultCursorDriver property must be set to dbUseODBCCursor when executing such queries. The NextRecordset method will return True even if some or all of the SELECT statements return zero records — it will return False only after all the individual SQL clauses have been checked.

Sub NextRecordsetX()

    Dim wrkODBC As Workspace
    Dim conPubs As Connection
    Dim rstTemp As Recordset
    Dim intCount As Integer
    Dim booNext As Boolean

    ' Create ODBCDirect Workspace object and open Connection
    ' object. The DefaultCursorDriver setting is required
    ' when using compound SQL statements.
    Set wrkODBC = CreateWorkspace("", _
        "admin", "", dbUseODBC)
    wrkODBC.DefaultCursorDriver = dbUseODBCCursor
    Set conPubs = wrkODBC.OpenConnection("Publishers", , , _
        "ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers")

    ' Construct compound SELECT statement.
    Set rstTemp = conPubs.OpenRecordset("SELECT * " & _
        "FROM authors; " & _
        "SELECT * FROM stores; " & _
        "SELECT * FROM jobs")

    ' Try printing results from each of the three SELECT
    ' statements.
    booNext = True
    intCount = 1
    With rstTemp
        Do While booNext
            Debug.Print "Contents of recordset #" & intCount
            Do While Not .EOF
                Debug.Print , .Fields(0), .Fields(1)
                .MoveNext
            Loop
            booNext = .NextRecordset
            Debug.Print "    rstTemp.NextRecordset = " & _
                booNext
            intCount = intCount + 1
        Loop
    End With

    rstTemp.Close
    conPubs.Close
    wrkODBC.Close

End Sub
Another way to accomplish the same task would be to create a prepared statement containing the compound SQL statement. The CacheSize property of the QueryDef object must be set to 1, and the Recordset object must be forward-only and read-only.

Sub NextRecordsetX2()

    Dim wrkODBC As Workspace
    Dim conPubs As Connection
    Dim qdfTemp As QueryDef
    Dim rstTemp As Recordset
    Dim intCount As Integer
    Dim booNext As Boolean

    ' Create ODBCDirect Workspace object and open Connection
    ' object. The DefaultCursorDriver setting is required
    ' when using compound SQL statements.
    Set wrkODBC = CreateWorkspace("", _
        "admin", "", dbUseODBC)
    wrkODBC.DefaultCursorDriver = dbUseODBCCursor
    Set conPubs = wrkODBC.OpenConnection("Publishers", , , _
        "ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers")

    ' Create a temporary stored procedure with a compound
    ' SELECT statement.
    Set qdfTemp = conPubs.CreateQueryDef("", _
        "SELECT * FROM authors; " & _
        "SELECT * FROM stores; " & _
        "SELECT * FROM jobs")
    ' Set CacheSize and open Recordset object with arguments
    ' that will allow access to multiple recordsets.
    qdfTemp.CacheSize = 1
    Set rstTemp = qdfTemp.OpenRecordset(dbOpenForwardOnly, _
        dbReadOnly)

    ' Try printing results from each of the three SELECT
    ' statements.
    booNext = True
    intCount = 1
    With rstTemp
        Do While booNext
            Debug.Print "Contents of recordset #" & intCount
            Do While Not .EOF
                Debug.Print , .Fields(0), .Fields(1)
                .MoveNext
            Loop
            booNext = .NextRecordset
            Debug.Print "    rstTemp.NextRecordset = " & _
                booNext
            intCount = intCount + 1
        Loop
    End With

    rstTemp.Close
    qdfTemp.Close
    conPubs.Close
    wrkODBC.Close

End Sub