Howlsta
Vampire Slayer
- Local time
- Today, 23:09
- Joined
- Jul 18, 2001
- Messages
- 180
I've built a form where for instance a member of staff enters their name and ID to logon. The problem is i built the form using help from wizard to open the next form. I wanted to link criteria for ID and Name. I linked the open operation by ID and tried to add the code to check if the name corresponds to the ID. The code below only seems to check if the ID is valid, and even so it seems to allow the user to enter values which don't exist in the table!
Can anyone help improve this code to make the system check that ID and name are valid, please??
Private Sub cmdGo_Click()
On Error GoTo Err_cmdGo_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim stLinkName As String
stDocName = "frmstaffswitchboard"
stLinkCriteria = "[StaffID]=" & Me![txtStaffID]
stLinkName = "[FirstName]=" & "'" & Me![txtName] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.OpenForm stDocName, , , stLinkName
Exit_cmdGo_Click:
Exit Sub
Err_cmdGo_Click:
If IsNull(Me.txtStaffID) Or IsNull(Me.txtName) Then
MsgBox "Name or ID is Blank"
Else
MsgBox Err.Description
End If
Resume Exit_cmdGo_Click
Can anyone help improve this code to make the system check that ID and name are valid, please??
Private Sub cmdGo_Click()
On Error GoTo Err_cmdGo_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim stLinkName As String
stDocName = "frmstaffswitchboard"
stLinkCriteria = "[StaffID]=" & Me![txtStaffID]
stLinkName = "[FirstName]=" & "'" & Me![txtName] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.OpenForm stDocName, , , stLinkName
Exit_cmdGo_Click:
Exit Sub
Err_cmdGo_Click:
If IsNull(Me.txtStaffID) Or IsNull(Me.txtName) Then
MsgBox "Name or ID is Blank"
Else
MsgBox Err.Description
End If
Resume Exit_cmdGo_Click