I have a form called frmChecks, with a textbox txtSearchBox. The After Update event for txtSearchBox is connected to code that searches for the inputted value in a linked table (tblEmployees):
Expand|Select|Wrap|Line Numbers
- Dim rst As DAO.Recordset
- Dim strCriteria As String, errStr As String
- strCriteria = "[tblEmployees].[fldEmplNum] Like '*" & Me!txtSearchBox.Value & "*'"
- errStr = "Employee not found..."
- Set rst = Me.RecordsetClone
- rst.Requery
- rst.FindFirst strCriteria
- If rst.NoMatch Then
- MsgBox errStr, vbInformation, "Check Tracking System"
- rst.MoveFirst
- End If
- Me.Bookmark = rst.Bookmark
- Me!cboCheckNum = rst!fldCheckNum
- rst.Close
- Set rst = Nothing
Expand|Select|Wrap|Line Numbers
- Dim rst As DAO.Recordset
- Dim strCriteria As String
- strCriteria = "[tblEmployees].[fldEmplNum] Like '*" & Me!txtEmplERN.Value & "*'"
- Set rst = Me.RecordsetClone
- rst.Requery
- rst.FindFirst strCriteria
- If rst.NoMatch Then
- 'Code to raise not found error
- Else
- 'Code to do some other stuff during normal execution
- End If
- rst.Close
- Set rst = Nothing
The problem is that the second set of code won't work! It always executes the error branch of the If statement, even though I type in values that are definitely in the table, and which are found by the first set of code. I just don't get it...
Any thoughts? Thank you.