Form with Filter Buttons (Error '2448')

G

Guest

When I enter criteria (a for example) and hit the filter button that I
created on the form, a message box displays, Run-Time Error ‘2448’: You
can’t assign a value to this object.



When I Debug the code (I tried the Debug.Print cmd), ([TOOL NO]) Like
"*a*") appears in the immediate window. When I scroll my pointer over
Me.Filter = strWhere, it says Me.Filter = “([TOOL NO]) Like "*a*")â€.



This form is pulling information from two tables. The main table gives most
of the information about the Tool (desc, item no, owned by, etc..), and the
other table includes only the Tool No and the Location so that I can clear
out that information every year when we run a new inventory (which will also
allow me to save the previous location). The two tables have a one to one
relationship, so I did not think that it should be a problem. Does anybody
know what I may be wrong?


Thanks,
sept2006

Code for Filter_Click() is below,

Private Sub cmdFilter_Click()

Dim strWhere As String

Dim lngLen As Long





If Not IsNull(Me.txtFilterToolNo) Then

strWhere = strWhere & "([TOOL NO]) Like ""*" & Me.txtFilterToolNo &
"*"") AND "

End If



If Not IsNull(Me.txtFilterItemNo) Then

strWhere = strWhere & "([ITEM NO]) Like ""*" & Me.txtFilterItemNo &
"*"") AND "

End If



If Not IsNull(Me.txtFilterOwnedBy) Then

strWhere = strWhere & "([OWNED BY]) Like ""*" & Me.txtFilterOwnedBy
& "*"") AND "

End If



If Not IsNull(Me.txtFilterComments) Then

strWhere = strWhere & "([COMMENTS]) Like ""*" & Me.txtFilterComments
& "*"") AND "

End If





lngLen = Len(strWhere) - 5

If lngLen <= 0 Then

MsgBox "No criteria.", vbInformation, "Cannot narrow Results."

Else

strWhere = Left$(strWhere, lngLen)

Debug.Print strWhere

Me.Filter = strWhere

Me.FilterOn = True

End If

End Sub

'(Code is referenced from Allen Browne, http://allenbrowne.com/ser-62.html)
 
G

Guest

Nevermind,

I tried long and hard to find my error, and then ten minutes after I post it
becomes obvious to me. I had an extra ) in my code (noticed it in the
immediate window).

Sorry if anybody already spend time on this.

Sept2006
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top