Results 1 to 6 of 6
  1. #1
    wcrimi is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    142

    Thumbs up Get the exact "Like" value Issue On my Query

    I have a table of information that contains the distance of a race. I have a simple query that only brings up the relevant information for the exact distance I want or for all distances if I leave it black.



    The is the statement I am using.

    Like "*" & [Enter the Distance:] & "*"

    If I leave it blank it brings up every distance just like I want.

    If I enter 6F (which means 6 furlongs), 5F (5 furlongs), 1M (1 mile), 1 1/16M, 1 1/8M etc.. it works fine.

    Here's the problem.

    One of the table values is 7F (7 furlongs) and another is ab.7F (which means about 7F).

    If I enter 7F it brings up BOTH 7F and ab.7F. I just want 7F (this the the problem)

    If I enter ab.7F it brings up just ab.7F. That's correct.

    Is there any way to code that statement so that if I enter 7F I only get the 7F and not both 7F and ab.7F?

    Thanks

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Have you tried = "7F"?
    you could try

    Like "7F*" (total guess)

  3. #3
    wcrimi is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    142
    That was my first guess also. It didn't return anything.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    If LIKE "7F*" doesn't work then there must be some text in front of the 7 in the data.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    wcrimi is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    142
    Quote Originally Posted by June7 View Post
    If LIKE "7F*" doesn't work then there must be some text in front of the 7 in the data.

    This worked if I hard coded it straight into the query, but there are many distances. My goal here is to be prompted to enter the distance I want and get just that one. I don't want to have to keep changing the query.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I NEVER use dynamic parameterized queries. Cannot validate user input. Recommend binding form or report to query and using a form to input parameter to an UNBOUND textbox or combobox. Review http://www.allenbrowne.com/ser-62.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  2. Replies: 1
    Last Post: 07-10-2015, 06:33 AM
  3. Replies: 1
    Last Post: 02-05-2015, 05:41 PM
  4. Issue with "Group by" in a query
    By Chatholo in forum Queries
    Replies: 11
    Last Post: 07-17-2013, 09:08 PM
  5. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 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