Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    RichXB is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Jan 2014
    Posts
    6
    Quote Originally Posted by ssanfu View Post



    Code:
    Private Sub cmdOpenGym_Click()
        DoCmd.OpenForm "frmGymnastFilter", , "gymnastID = " & Me.gymnastID
    End Sub
    This is provided "Me.gymnastID" is a number....

    just thinking, gymnastID is a unique (albeit alphanumeric) reference, right? In that case steve's code above just needs to consider it as a string.



    Code:
    Private Sub cmdOpenGym_Click()
        DoCmd.OpenForm "frmGymnastFilter", , "gymnastID = '" & Me.gymnastID & "'"
    End Sub
    This is assuming the gymnastID is identical in whichever table you're pulling the data from. If it's linked by a different primary key you'll go nowhere like this.

  2. #17
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265
    Quote Originally Posted by orange View Post
    Try this --we're trying to remove the double quotes in the rendered/final string. You want this in the rendered string 'GymnastID Like '*33G*'


    Forms!frmGymnastFilter.Filter = "GymnastID Like '*"" & Me.gymnastID & "*'""
    I tried your suggestion and it didn't work. To make this even more simple, I am trying the following code to filter a field on the existing form (no opening another form). I am getting a syntax error. If I can't get this, then I double I can get something more complex like my original example. Single quotes and double quotes do not work. I don't know what else to try.

    Private Sub cmdFullName_Click()
    fullNameG LIKE 'D*'
    End Sub

  3. #18
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

  4. #19
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265
    I just got an error message. But I found the answer:

    Private Sub cmdFullName_Click()
    DoCmd.OpenForm "frmGymnastFilter", acNormal
    Forms!frmGymnastFilter.Filter = "GymnastID Like '*" & Me.gymnastID & "*'"
    Forms!frmGymnastFilter.FilterOn = True
    End Sub

    Thank you for all of your help.

  5. #20
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

  6. #21
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265
    Now that I got it to work, I want to try your other suggestion, where I embed the filter in the openForm command. But it's not working. Here is what I have:


    Private Sub cmdFilterGymnastID_Click()
    DoCmd.OpenForm "frmGymnastFilter", acNormal, "GymnastID Like '*" & Me.gymnastID & "*'"
    End Sub

    The filter is exactly the same as it was when I got it to work by using the Form's filter property. I can't find anything wrong.

  7. #22
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Use the WhereCondition parameter in the OPenArgs

    see http://www.datawright.com.au/access_..._arguments.htm

    I think all you need is an extra comma in your OPenForm

    DoCmd.OpenForm "frmGymnastFilter", acNormal, , "GymnastID Like '*" & Me.gymnastID & "*'"

    Give it a try.

  8. #23
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265
    Quote Originally Posted by orange View Post
    Use the WhereCondition parameter in the OPenArgs

    see http://www.datawright.com.au/access_..._arguments.htm

    I think all you need is an extra comma in your OPenForm

    DoCmd.OpenForm "frmGymnastFilter", acNormal, , "GymnastID Like '*" & Me.gymnastID & "*'"

    Give it a try.
    I guess there was a misunderstanding on my part. I thought I was using the 3rd argument called "FilterName." How would you use that argument?

    By the way, that additional comma did work as the WHERE argument.

  9. #24
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Look at the link, he says it should be a query. I didn't test or confirm it, but I have a lot of respect for him and his site.

    What is the recordsource of your Form?

  10. #25
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I have always used the where condition and never used the Filter Name. Not sure how to use the filter name. Ironically, Access 2010 applies the Where Condition to the form's filter property. At least, this has been my experience.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  2. Replies: 9
    Last Post: 01-22-2013, 04:23 PM
  3. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  4. Syntax error missing operator(3075)
    By parisienne in forum Programming
    Replies: 1
    Last Post: 04-07-2011, 02:29 PM
  5. Syntax Error...missing operator
    By jgelpi16 in forum Programming
    Replies: 14
    Last Post: 09-09-2010, 11:35 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums