Allen Browne Filter DB

P

PHuser

I have copied Allen Browne's Search DB But I keep getting the error "You
Can't assign a value to this object" and highlights the Me.Filter = strWhere

What am I doing wrong? And I do have 1 question in a query you can use the
"Like" command when looking up a number how come it can't be used for this?
I have tried both.

Private Sub CmdFilter_Click()

Dim strWhere As String
Dim lngLen As Long

If Not IsNull(Me.InvNumber) Then
strWhere = strWhere & "([PONumber] Like "" * " & Me.InvNumber & " *
"") AND"
End If

If Not IsNull(Me.InvAmount) Then
strWhere = strWhere & ([txtTotal] Like "*" & Me.InvAmount & "*")
End If

lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)

Me.Filter = strWhere
Me.FilterOn = True

End If



End Sub
 
A

Allen Browne

If you cannot assign a value to the Filter of the form, there could be
several reasons, such as:
- The form is unbound (i.e. there is nothing in the RecordSource property of
the form.)

- The event you are trying to use is not appropriate (e.g. other events must
complete first.)

- You tried this in a module that is not the module of a form.

If the filter string was invalid, I would expect the FilterOn line to fail.

For your example with the Like operator, try just one field at a time until
you get that working, and then build up the others. The first one looks like
it contains spurious spaces around the asterisks.
 

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

Similar Threads


Top