All, I am having trouble with this code to filter the SSN in an unbound field on a form. I’ve done it two ways. See code.
Code:
Private Sub SSN_AfterUpdate()
' Find the record that matches the control.
' Dim rs As Object
' Set rs = Me.Recordset.Clone
' rs.FindFirst "[SSN] = '" & Me![ssn] & "'"
' If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.Filter = "[SSN] = " & Chr(34) & Me.[SSN] & Chr(34)
Me.FilterOn = True
Me.SSN = ""
End Sub
One is comment out to try the other code. When I first enter a number; it finds the related record. But if I enter another number; it auto fills a number and just beeps without giving an error and it doesn’t find the record. It’s not until I hit a reset button to clear all fields on the form does it accepts another number to find a new record. I have an input mask for the SSN in the unbound field because the SSN in the table all have hyphens. I don’t know a way of not using it without the input mask as the users prefer in order to find the records with hyphens. I don’t understand why this happens when I use the same code for a last name search or customer number search and I can perform another search without resetting the form. See code.
Code:
Private Sub cboLname_AfterUpdate()
' Find the record that matches the control.
Me.Filter = "[LastName] = " & Chr(34) & Me.cboLname & Chr(34)
Me.FilterOn = True
Me.cboLname = ""
All the fields are text fields. The only thing different I can see is the input mask on the SSN. Please help.