SOLVED: Search Form & Error Messages
Hi All,
I have two unbound text boxes and a search button adjacent each that allows me to search for a user via two methods:
1) Payroll ID
2) Surname
They have the following code:
txtPayrollIDSearch
cmdPayrollIDSearch
Then minor differences between the above and the Surname search.
I have two questions:
1) How do I make the search more friendly by allowing it to find partial matches, i.e., a user has a surname of 'Smith' but I want to search for 'Smi'?
2) How can I display further error messages if there aren't any matches?
Hi All,
I have two unbound text boxes and a search button adjacent each that allows me to search for a user via two methods:
1) Payroll ID
2) Surname
They have the following code:
txtPayrollIDSearch
Code:
Private Sub txtPayrollIDSearch_AfterUpdate()
Dim sWHERE As String
sWHERE = "[PayrollID] = " & Me.txtPayrollIDSearch
sWHERE = "[PayrollID] = '" & Me.txtPayrollIDSearch & "'"
DoCmd.OpenForm "frmUser", acNormal, , sWHERE, acFormEdit
Forms!frmUser.Header0.Caption = "Edit User"
Forms!frmUser.txtPayrollID.Enabled = False
Forms!frmUser.txtForename.Enabled = False
Forms!frmUser.txtSurname.SetFocus
End Sub
cmdPayrollIDSearch
Code:
Private Sub cmdPayrollIDSearch_Click()
If IsNull(Me.txtPayrollIDSearch.Value) Then
MsgBox "Please enter a value", 48, "Search Failed"
Else
Dim sWHERE As String
sWHERE = "[PayrollID] = " & Me.txtPayrollIDSearch
sWHERE = "[PayrollID] = '" & Me.txtPayrollIDSearch & "'"
DoCmd.OpenForm "frmUser", acNormal, , sWHERE, acFormEdit
Forms!frmUser.Header0.Caption = "Edit User"
Forms!frmUser.txtPayrollID.Enabled = False
Forms!frmUser.txtForename.Enabled = False
Forms!frmUser.txtSurname.SetFocus
End If
End Sub
Then minor differences between the above and the Surname search.
I have two questions:
1) How do I make the search more friendly by allowing it to find partial matches, i.e., a user has a surname of 'Smith' but I want to search for 'Smi'?
2) How can I display further error messages if there aren't any matches?
Last edited: