gojets1721
Registered User.
- Local time
- Today, 15:33
- Joined
- Jun 11, 2019
- Messages
- 430
I've got a Complaints table and an Employees table. Both tables share a 'ComplaintNumber' field.
In the Complaints form, I was hoping to use a input box to allow the user to search an employees name (from the Employees table) and it filters down to matching ComplaintNumber(s) based on that employee's name.
Here's what I've got so far. The input box opens up but doesn't do anything. No error; it just doesn't filter anything.
In the Complaints form, I was hoping to use a input box to allow the user to search an employees name (from the Employees table) and it filters down to matching ComplaintNumber(s) based on that employee's name.
Here's what I've got so far. The input box opens up but doesn't do anything. No error; it just doesn't filter anything.
Code:
Private Sub btnSearchEmployee_Click()
On Error GoTo btnSearchEmployee_Click_Err
Dim S As String
Dim rst As DAO.Recordset
S = InputBox("Enter Employee Name", "Employee Name Search")
If S = "" Then Exit Sub
strSQL = "Select * from tblEmployees where EmployeeName LIKE ""*" & S & "*"""
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
If rst.EOF = False Then
Me.Recordset.FindFirst "ComplaintNumber = " & rst!ComplaintNumber
End If
btnSearchEmployee_Click_Exit:
Exit Sub
btnSearchEmployee_Click_Err:
MsgBox "Error #" & Err.Number & " - " & Err.Description, , "Error"
Resume btnSearchEmployee_Click_Exit
End Sub