Run Time Error 3709: The Search Key was not found in any Record

richard05

Registered User.
Local time
Today, 12:05
Joined
Mar 18, 2009
Messages
10
Hello

I have a problem with the following code, and hope if someone could give me some guidance, to where I am going wrong. Basically I am looking to filter the variable "YearsInJob" by allowing user to enter a value less than or equal to whatever value is entered into the textbox.

Code:
If Not IsNull(Me.txtyearsinjob) Then
    strWhere = strWhere & "([YearsInJob] <= " & Me.txtyearsinjob & ") AND "
End If

When try to run the filter criteria I receive the following error message
"Run Time Error 3709: The Search Key was not found in any Record"
 
SOLVED: Changed the data type of the field, which sorted the issue.
 
I'm guessing it was text and you changed it to a number? If so, the reason why it didn't work before is with text fields you need to encapsulate your value in quotes like this:

strWhere = strWhere & "([YearsInJob] <= " & Chr(34) & Me.txtyearsinjob & Chr(34) & ") AND "

or like

strWhere = strWhere & "([YearsInJob] <= '" & Me.txtyearsinjob & "') AND "

or like

strWhere = strWhere & "([YearsInJob] <= " & """ & Me.txtyearsinjob & """ & ") AND "
 
Yeah it was originally a text field. Cheers for the other suggestions, it was frying my head to why wasn't working.
 

Users who are viewing this thread

Back
Top Bottom