Results 1 to 4 of 4
  1. #1
    jachbow is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2021
    Posts
    4

    Ignoring Extra Spaces in Parameter Query

    I am trying to get my query so that any extra spaces before or after the user's input is ignored. I've already tried the criteria: Like "*"&[Enter .......]&"*"


    Is this straight up wrong or is there a minor syntax error?
    Also, if I were to want two parameters/an Or how would that look?
    - I've been doing: Like "*"&[Enter .......]&"*" Or Like "*"&[Enter .......]&"*"


    Thank you!

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Use Trim() ?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    jachbow is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2021
    Posts
    4
    That definitely seems like the exact thing I was looking for. I started learning Access a few days ago so I'm still kind of unfamiliar with the available functions.

    Thanks for the help!

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    With regards your second question, you probably don’t want the same prompt text - could just add or remove a dot. And there should be spaces either side of the & though that may just be the way you have posted it.

    And that should work in the query builder but is constructed differently in sql. Switch to sql view of your query to see what I mean

    Whether to use OR or not depends on what you want, if the two entries are Sam and Fred then both will be returned. The alternative is to put on separate lines in the query builder - and repeat any other criteria you may have on both lines

    Not clear whether you are trying to use * to get around the space problem but if not required, use = rather than like

    And what do you want to happen if the user doesn’t enter anything for one or both prompts?

    Generally better to use a form for the user to enter the search terms and have the query reference the form. Users should not be working directly with queries anyway

    Good luck with your project

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

Similar Threads

  1. Replies: 4
    Last Post: 09-13-2018, 10:21 AM
  2. Replies: 12
    Last Post: 04-06-2018, 01:46 PM
  3. Replies: 9
    Last Post: 02-25-2017, 09:15 PM
  4. How to remove extra spaces from a field?
    By accessmatt in forum Queries
    Replies: 1
    Last Post: 09-22-2014, 06:57 AM
  5. Replies: 2
    Last Post: 04-11-2013, 06:36 PM

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