• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 27. STARTUP CHECKING SYSTEM ROUT... > REPLICATING CODE TABLES USING ADO

REPLICATING CODE TABLES USING ADO

Although Chapter 28 discusses replicating code tables, I thought it would be worthwhile to look briefly at ap_CheckReplicatedTables in this chapter (see Listing 27.6).

Listing 27.6. VideoApp(ADO).mdb: Replicating Code Tables

Sub ap_CheckReplicatedTables()

   Dim catLocal As New ADOX.Catalog
   Dim rstCheckRep As New ADODB.Recordset
   Dim cmdUpdateRep As New ADODB.Command
   Dim strTableName As String

   On Error GoTo Error_ap_CheckReplicatedTables

   Set catLocal.ActiveConnection = CurrentProject.Connection

   DoCmd.Echo True, "Checking for Replicated Tables..."

   '-- Attach the backend replicated table
   '-- and open the query that shows updated replicated tables
   On Error Resume Next

   catLocal.Tables.Delete "tblBackEndReplicatedTables"
   catLocal.Tables.Refresh

   On Error GoTo Error_ap_CheckReplicatedTables

   ap_CreateLinkedTableWithADO catLocal, "tblBackEndReplicatedTables", _
                "tblReplicatedTables", pstrBackEndPath & pstrBackEndName
   catLocal.Tables.Refresh

   Set cmdUpdateRep = _
      catLocal.Procedures("qryUpdateLastReplication").Command

   rstCheckRep.Open "qryCheckBackEndReplication", _
      CurrentProject.Connection, adOpenStatic

   '-- If a table has been updated, loop through


   Do Until rstCheckRep.EOF
      DoCmd.Echo True, "Replicating " & rstCheckRep!TableName & _
            ", Please wait..."

      '-- Delete the current local table,
      '-- and import the backend table
      On Error Resume Next
      strTableName = rstCheckRep!TableName

      catLocal.Tables.Delete strTableName
      catLocal.Tables.Refresh

      On Error GoTo Error_ap_CheckReplicatedTables

      DoCmd.TransferDatabase acImport, "Microsoft Access", _
         pstrBackEndPath & pstrBackEndName, acTable, _
         rstCheckRep!TableName, rstCheckRep!TableName

      catLocal.Tables.Refresh

      cmdUpdateRep.Parameters("CurrReplicatedTable") = strTableName
      cmdUpdateRep.Execute

      rstCheckRep.MoveNext
   Loop

   catLocal.Tables.Delete "tblBackEndReplicatedTables"

   DoCmd.Echo True

   '-- Clean up
   rstCheckRep.Close

   Exit Sub

Error_ap_CheckReplicatedTables:
   MsgBox Err.Description
   Resume 'Exit Sub

End Sub


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint