home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Software Sampler
/
Visual_Basic_Software_Sampler_Visual_Basic_Programmers_Journal_June_1996.iso
/
issues
/
03mar96
/
code
/
p50lst1.txt
< prev
next >
Wrap
Text File
|
1996-01-31
|
2KB
|
95 lines
(c) 1996 VISUAL BASIC PROGRAMMER'S JOURNAL
FAWCETTE TECHNICAL PUBLICATIONS
FILE NAME: PLMA96L.DOC (Listing for Paul Litwin's Jet Replication article)
ISSUE: MARCH 96
EDITOR: MC
SECTION: FEATURES
STATUS: FIRST EDIT
Listing 1.
Function glrDbSync(ByVal strFromDb As String, _
ByVal strToDb As String, _
Optional ByVal varExchType As Variant) As Boolean
' Synchronizes two databases
' varExchType must be one of following constants:
' dbRepImpExpChanges (the default),
' dbRepExportChanges, or
' dbRepImportChanges
' Returns True if successful; otherwise returns False
On Error GoTo glrDbSync_Err
Dim dbFrom As Database
glrDbSync = False
Set dbFrom = _
DBEngine.Workspaces(0).OpenDatabase(strFromDb)
If IsMissing(varExchType) Then _
varExchType = dbRepImpExpChanges
dbFrom.Synchronize strToDb, varExchType
glrDbSync = True
glrDbSync_Exit:
On Error GoTo 0
Exit Function
glrDbSync_Err:
Select Case Err
Case Else
MsgBox "Error" & Err.Number & ": " & _
Err.Description, vbOKOnly + _
vbCritical, "Synchronize Replicas"
End Select
Resume glrDbSync_Exit
End Function
Listing 2.
Private Sub cmdCount_Click()
On Error Resume Next
' Count the number of updated/new
' records in any replicated tables
' in this database
Dim lngTotal As Long
Dim ctlCount As TextBox
Dim ctlLabel As Label
Dim db As Database
Dim tdf As TableDef
Dim rst As Recordset
Screen.MousePointer = vbHourglass
Set ctlCount = Me!txtCount
Set ctlLabel = Me!lblCount
Set db = DBEngine.Workspaces(0).OpenDatabase(txtDb)
lngTotal = 0
For Each tdf In db.TableDefs
If tdf.Properties!Replicable = "T" Then
Set rst = db.OpenRecordset(_
"SELECT COUNT(*) AS Cnt FROM " & _
tdf.Name & _
" WHERE [s_Generation]=0;")
lngTotal = lngTotal + rst!Cnt
End If
Next tdf
ctlCount = lngTotal
ctlCount.Enabled = True
ctlLabel.Enabled = True
Screen.MousePointer = vbDefault
End Sub