crisis2007
Technical User
I have the following code on a main form command button that is intended to pop-up a second form. This second form is supposed to synchronize using the RosterID as a common field. This second form, based on a different table allows me to enter data. But the code does not seem to populate the textbox and synchronize the second form (F_Stat2) as I intend. I am using ms access 2003. Any assistance is greatly appreciated. I am still learning vba and am not proficient in it.
Private Sub Command113_Click()
'If the employee number is blank, then exit the Sub.
If IsNull(Me.[EmployeeNumber]) Then
Exit Sub
End If
'Dimension variables.
Dim FormName As String, SyncCriteria As String
Dim frm As Form, rs As DAO.Recordset
'Set the formname to "F_Stat2," the form that will be
'synchronized.
FormName = "F_Stat2"
'Check to see if the F_Stat2 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 F_Stat2 form.
Set frm = Forms(FormName)
Set rs = frm.RecordsetClone
'Define the criteria used for the synchronization.
SyncCriteria = BuildCriteria("RosterID", dbInteger, Me.txtRosterID)
'Synchronize the corresponding record in the F_Stat2 form to
'the current record in the F_NorthEdit
rs.FindFirst SyncCriteria
'If a record exists in the F_NorthEdit form, find the
'matching record.
If rs.NoMatch Then
MsgBox "No match exists!", 64, FormName
Else
frm.Bookmark = rs.Bookmark
End If
End Sub
Private Sub Command113_Click()
'If the employee number is blank, then exit the Sub.
If IsNull(Me.[EmployeeNumber]) Then
Exit Sub
End If
'Dimension variables.
Dim FormName As String, SyncCriteria As String
Dim frm As Form, rs As DAO.Recordset
'Set the formname to "F_Stat2," the form that will be
'synchronized.
FormName = "F_Stat2"
'Check to see if the F_Stat2 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 F_Stat2 form.
Set frm = Forms(FormName)
Set rs = frm.RecordsetClone
'Define the criteria used for the synchronization.
SyncCriteria = BuildCriteria("RosterID", dbInteger, Me.txtRosterID)
'Synchronize the corresponding record in the F_Stat2 form to
'the current record in the F_NorthEdit
rs.FindFirst SyncCriteria
'If a record exists in the F_NorthEdit form, find the
'matching record.
If rs.NoMatch Then
MsgBox "No match exists!", 64, FormName
Else
frm.Bookmark = rs.Bookmark
End If
End Sub