Fliter

R

Richard

Hi all,

Im trying to fliter my form using a unbound textbox and a command button. If
the user inputs a partial string or exact string, either way i want the
results to filter.

Private Sub cmdPhoneNumber_Click()
' Find the record that matches the control.
Dim stFilter As String

Me.FilterOn = False

stFilter = [Phone] Like "*" & Me.txtPhoneNumber & "*"


Me.Filter = stFilter
Me.FilterOn = True

End Sub

I can't seem to get this to filter correctly.

Richard
 
F

fredg

Hi all,

Im trying to fliter my form using a unbound textbox and a command button. If
the user inputs a partial string or exact string, either way i want the
results to filter.

Private Sub cmdPhoneNumber_Click()
' Find the record that matches the control.
Dim stFilter As String

Me.FilterOn = False

stFilter = [Phone] Like "*" & Me.txtPhoneNumber & "*"


Me.Filter = stFilter
Me.FilterOn = True

End Sub

I can't seem to get this to filter correctly.

Richard

The Filter must be a string.

strFilter = "[Phone] Like '*" & Me.[txtPhoneNumber] & "*'"
 
R

Richard

Hi Fred

I changed this line as per your suggestion, but now I get a compile error:
variable not defined.

strFilter = "[Phone] Like '*" & Me.[txtPhoneNumber] & "*'"



fredg said:
Hi all,

Im trying to fliter my form using a unbound textbox and a command button. If
the user inputs a partial string or exact string, either way i want the
results to filter.

Private Sub cmdPhoneNumber_Click()
' Find the record that matches the control.
Dim stFilter As String

Me.FilterOn = False

stFilter = [Phone] Like "*" & Me.txtPhoneNumber & "*"


Me.Filter = stFilter
Me.FilterOn = True

End Sub

I can't seem to get this to filter correctly.

Richard

The Filter must be a string.

strFilter = "[Phone] Like '*" & Me.[txtPhoneNumber] & "*'"
 
R

Richard

Never mind

You added an "R" to stFilter now it works great thanks Fred.



fredg said:
Hi all,

Im trying to fliter my form using a unbound textbox and a command button. If
the user inputs a partial string or exact string, either way i want the
results to filter.

Private Sub cmdPhoneNumber_Click()
' Find the record that matches the control.
Dim stFilter As String

Me.FilterOn = False

stFilter = [Phone] Like "*" & Me.txtPhoneNumber & "*"


Me.Filter = stFilter
Me.FilterOn = True

End Sub

I can't seem to get this to filter correctly.

Richard

The Filter must be a string.

strFilter = "[Phone] Like '*" & Me.[txtPhoneNumber] & "*'"
 

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