search criteria not returning values

TIbbs

Registered User.
Local time
Today, 13:44
Joined
Jun 3, 2008
Messages
60
I run this vba code to allow me to filter data in a form.
The form is bound to a query with ACCOUNT_REF part of the query and txtFilterAccountRef an unbound control box.

I am trying to view a specific account with input provided by a user.
I am getting an error message that says:

"Run time error 2448
You can't assign a value to this object."

This is the code I am using:


Option Compare Database

Private Sub OK2_Click()

Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"

If Not IsNull(Me.txtFilterAccountRef) Then
strWhere = strWhere & "([ACCOUNT_REF]=""" & Me.txtFilterAccountRef & """) AND"
End If


lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)
Debug.Print strWhere
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub


Any idea what is causing it to happen?
 

Users who are viewing this thread

Back
Top Bottom