Results 1 to 12 of 12
  1. #1
    SteveFlash is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    39

    Using two textboxes to query Between two values. X < X

    I am trying to set up a form with two text boxes so I can run a query that searches for records with values between a two numbers. In the query design view I was able to do this by placing the following in the criteria statement of the field titled "Amount":

    Between 10 And 50

    Because this worked I tried to use the following to have the query reference the two text boxes on my form:



    Between [Forms]![Search]![AvgAmtO] And [Forms]![Search]![AvgAmt2]

    but this doesn't work. Does anyone one know how to do this or have any advice?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    It would help to know what "doesn't work" means, as it should. Make sure you've tabbed off the second form control before running the query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    SteveFlash is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    39
    It just brings back result without taking the two values in the text boxes into account. If I was to put say "10 to 20" in the two text boxes on the form and then press the button to lunch the query the results I get will have avg amounts from 1 to 10,000.

    What do you mean by tabbed off the second form control in the query?

  4. #4
    SteveFlash is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    39

    Using two text boxes on a form to query Between two values. X < Y

    I am trying to set up a form with two text boxes so I can run a query that searches for records with values between a two numbers. In the query design view I was able to do this by placing the following in the criteria statement of the field titled "Amount":

    Between 10 And 50

    Because this worked I tried to use the following to have the query reference the two text boxes on my form:

    Between [Forms]![Search]![AvgAmtO] And [Forms]![Search]![AvgAmt2]

    but when I run the query from the form it brings back people with all AvgAmt ranges. Does anyone know what the proper criteria statement is?

  5. #5
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Your criteria looks to be ok. Are all your objects and controls spelled correctly? Double check for spaces,etc.

  6. #6
    SteveFlash is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    39
    The amount field is formatted as a number and I am inputting numbers. I can't for the life of me figure this out and it is so frustrating because I know the solution would take 30 seconds but I have spent hours.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I mean to move focus from it. Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    SteveFlash is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    39
    Ummm I can't really because it has some private info. Can this be done by simply adding a command to the criteria of the filed in the query design? Or does it require more work then I realize?

  9. #9
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    cross posted at: http://www.access-programmers.co.uk/...d.php?t=240473

    Please read this: http://www.excelguru.ca/content.php?184

    Take a look at this regarding the between function. http://www.techonthenet.com/sql/between.php

    Perhaps you would like to post a copy of your db for analysis and a fresh pair of eyes.

  10. #10
    SteveFlash is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    39
    Thanks Alan. I found to forums and decided to post the question in both, yes. I can preform the function no problem if I put in the numbers into it but if I try to reference the text boxes for the numbers that when it does not work. Do you know what might be the problem.

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I merged your threads; please don't post the same question twice.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Paul means you must Tab or Enter from each control after entering the criteria values.
    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: 12-04-2012, 02:50 PM
  2. Replies: 1
    Last Post: 11-28-2012, 04:14 PM
  3. Replies: 2
    Last Post: 11-12-2012, 03:52 AM
  4. Replies: 2
    Last Post: 05-17-2012, 03:52 PM
  5. Replies: 6
    Last Post: 07-01-2011, 02:11 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