Article ID: 149940
Article Last Modified on 1/19/2007
'**********************************************************
'Sub Form_Current()
'**********************************************************
'If the ProductName is blank, then exit the Sub.
If IsNull(Me![ProductName]) Then
Exit Sub
End If
'Dimension variables.
Dim formname As String, SyncCriteria As String
Dim f As Form, rs As Recordset
'Set the formname to "Products," the form that will be
'synchronized.
formname = "Products"
'Check to see if the Products form is open. If it
'is not open, open it.
If Not SysCmd(acSysCmdGetObjectState, acForm, formname) Then
DoCmd.OpenForm formname
End If
'Define the form object and Recordset object for
'the Products form.
Set f = Forms(formname)
Set rs = f.RecordsetClone
'Define the criteria used for the synchronization.
SyncCriteria = BuildCriteria("ProductName", dbText, _
Me!ProductName)
'Synchronize the corresponding record in the Products form to
'the current record in the subform.
rs.FindFirst SyncCriteria
'If a record exists in the Products form, find the
'matching record.
If rs.nomatch Then
MsgBox "No match exists!", 64, formname
Else
f.bookmark = rs.bookmark
End If
'**********************************************************
'End Sub
'**********************************************************Forms!Categories![Product List].Form
119398 ACC2: Using Code to Dynamically Synchronize Two Forms
Keywords: kbhowto kbprogramming kbusage KB149940