I have 2 forms that I'm trying to synchronize. I have an Access form called "Login". "Command10" is a button on the form and "Text5" is a text field on it. When a user enters a numeric value (InstructorID) in the Text5 text field and clicks the button Command10, it opens another form called "Existing Instructor", displaying the InstructorID and all the relevant information on the new form.
Here's the catch. Let's say there are 2 Instructors in the table, Joe and Sam with InstructorID 60 and 70 respectively. When I enter 60 in Text5 on the Login Form and click the button, it takes me to the Existing Instructor Form showing all the information for that instructor, namely Joe. But when I enter 70 (or any other existing value) in the Login Form and click the button, it still takes me to the Existing Instructor Form but it shows all the information for the first record(InstructorID = 60, InstructorLastName = Joe). How do I synchronize the forms so that when a certain InstructorID is entered on the Login form, the corresponding InstructorID and other information for that record are displayed on the Existing Instructor Form? Any help would be greatly appreciated.
Here's what I have tried. This is my OnClick procedure associated with the button Command10 on the form Login:
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Existing Instructor"
'Validation to see if Instructor Last Name and InstructorID match
If DCount("*", "Instructor", "[InstructorID] = " & Me!Text5 & " And [InstructLastName] = '" & Me!Text7 & "'") > 0 Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Instructor ID and Last Name do not match. Please try again"
End If
Exit_Command10_Click:
Exit Sub
Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click
End Sub
Thanks
Shal
Here's the catch. Let's say there are 2 Instructors in the table, Joe and Sam with InstructorID 60 and 70 respectively. When I enter 60 in Text5 on the Login Form and click the button, it takes me to the Existing Instructor Form showing all the information for that instructor, namely Joe. But when I enter 70 (or any other existing value) in the Login Form and click the button, it still takes me to the Existing Instructor Form but it shows all the information for the first record(InstructorID = 60, InstructorLastName = Joe). How do I synchronize the forms so that when a certain InstructorID is entered on the Login form, the corresponding InstructorID and other information for that record are displayed on the Existing Instructor Form? Any help would be greatly appreciated.
Here's what I have tried. This is my OnClick procedure associated with the button Command10 on the form Login:
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Existing Instructor"
'Validation to see if Instructor Last Name and InstructorID match
If DCount("*", "Instructor", "[InstructorID] = " & Me!Text5 & " And [InstructLastName] = '" & Me!Text7 & "'") > 0 Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Instructor ID and Last Name do not match. Please try again"
End If
Exit_Command10_Click:
Exit Sub
Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click
End Sub
Thanks
Shal