Results 1 to 3 of 3
  1. #1
    rushforth is offline Novice
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Aug 2010
    Posts
    14

    Exclamation Using wildcards with between workaround


    Hi,

    I have a query where I need to pull up all records between two numbers based on unbound text boxes. I also need to make it open enough so if one box is left blank then all records up to or below the entered amount are shown. Similarly if both boxes are blank then all records are shown.

    Here is my logic so far:

    BETWEEN "*" & [Forms]![Filters]![Text1] & "*" AND "*" & [Forms]![Filters]![Text2] & "*"

    I know you cant use wildcards with BETWEEN but is there a workaround?

    Thanks for any help.

    James

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    there really isn't a workaround to this. what you can do though, (one option), is to hide another box on the form that you're opening the qry from, and on the action that opens the qry, give the hidden boxes the appropriate values if one of the regular inputs are null. for instance:

    Code:
    where myfield BETWEEN 
    
    [Forms]![Filters]![Text1sub] 
    
    AND 
    
    [Forms]![Filters]![Text2sub]
    on the form, one could put behind the query event:
    Code:
    if isnull(me.text1) and isnull(me.text2) then
       me.text1sub = 0
       me.text2sub = 100000000000
    elseif isnull(me.text1) then
       me.text1sub = 0
    elseif isnull(me.text2) then
       me.text2sub = 100000000000
    else
    end if
    
    docmd.openquery "QUERY"
    the purpose of the really long number there is to give a ridiculous upper bound that no record could ever exceed.

  3. #3
    rushforth is offline Novice
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Aug 2010
    Posts
    14

    Smile

    Thanks! I used two hidden unbound text boxes on the form with =IIf([Text2] Is Null,"100000000",[Text2]) etc...

    This way it ensures if a box is populated then emptied the hidden box always shows "10000000" if null.

    Cheers for the idea though.

    James

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

Similar Threads

  1. Trailing Spaces workaround
    By shexe in forum Queries
    Replies: 23
    Last Post: 09-21-2010, 04:28 AM
  2. Using wildcards (*) in SQL
    By SIGMA248 in forum Queries
    Replies: 1
    Last Post: 07-22-2010, 08:44 PM
  3. Wildcards?!
    By esx_raptor in forum Access
    Replies: 3
    Last Post: 02-19-2010, 03:22 PM
  4. Replies: 3
    Last Post: 01-05-2010, 10:07 PM

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