where condition in a filter

R

Rick

I need to apply a filter where only records with a particular UserID are
displayed. I have a combo box called FindUser and a refresh button. When
the button is clicked, several things happen but the one I am having trouble
with is the userid filter. The field in my query and on my continuous form
is 'UserID'


Can you tell me what I am doing wrong in my syntax:

If Not [FindUser] = "" Then
DoCmd.ApplyFilter , "userID = [FindUser]"
End If


I have also tried:

If Not [FindUser] = "" Then
DoCmd.ApplyFilter , "userID = me.FindUser"
End If

and:

If Not [FindUser] = "" Then
DoCmd.ApplyFilter , userID = FindUser
End If
 
S

Sandra Daigle

Try leaving [Finduser] out of the quotes:

DoCmd.ApplyFilter , "userID =" & me.[FindUser]

If Userid is text then the value must be wrapped in quotes:

DoCmd.ApplyFilter , "userID =""" & me.[FindUser] & """"
 

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