Results 1 to 7 of 7
  1. #1
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727

    Problem with a query

    I have a query that works great and one that doesn't because I guess they work slightly different. The one that works great is a split form with an unbound text box with a filter button. This is what I have in the VBA editor:

    Me.Filter = "[Recorded By:] Like '*" & Me.txtFilter & "*'"

    It filters anything I type as if having a wild card at the front and end of the data I enter. This is what I want for my other query but can't seem to get it to work. I have this expression for a query in design view for the criteria parameter:



    Like [Forms]![Partial Criteria].[txtPermit] & "*"

    I'm pretty sure it has something to do with the * because I noticed the top VBA has an * with an & character before and after the text box but I'm not sure how to rewrite this for the bottom expression. Can someone assist with this?

    Thanks so much.

  2. #2
    Rod is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Like "'" & [Forms]![Partial Criteria].[txtPermit] & "*'"

  3. #3
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727
    Correction. Should be:

    Like "*" & [Forms]![Partial Criteria].[txtPermit] & "*"

    Thanks so much for the idea though. This pointed me in the right direction. Thanks again.

  4. #4
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    In design view, you don't need the double quotation: Like "*" & [Forms]![Partial Criteria].[txtPermit] & "*"
    Last edited by hapm; 06-04-2014 at 06:14 AM. Reason: sry, got ninja'd

  5. #5
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727
    I put this into design view for a query in the criteria row and it worked. When I tried what Rod gave, it didn't work.

  6. #6
    Rod is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Yup, hapm's correct. What I gave you was the VBA version. Sorry.

  7. #7
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727
    No problem. Your suggestion gave me the answer. I just needed to know where to place "*" &

    For this:
    Like [Forms]![Partial Criteria].[txtPermit] & "*"

    I thought the code would have been like this:
    Like [Forms]![Partial Criteria]."*" & [txtPermit] & "*"

    because I figured the wild card would have to be at the beginning of the txtPermit text box since that is the text box that the user will be typing in.

    Anyway, thanks for the help. I really appreciate it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Problem with query
    By shultzcarla in forum Access
    Replies: 8
    Last Post: 10-16-2012, 02:26 PM
  2. VBA problem in query
    By geniass in forum Queries
    Replies: 41
    Last Post: 08-28-2010, 03:07 PM
  3. Query problem
    By puppychew in forum Access
    Replies: 20
    Last Post: 02-01-2010, 09:43 AM
  4. query problem i have a problem wi
    By maxx3 in forum Queries
    Replies: 0
    Last Post: 06-29-2009, 02:29 AM
  5. problem with query
    By kiethb in forum Queries
    Replies: 3
    Last Post: 04-24-2009, 11:42 AM

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