Results 1 to 8 of 8
  1. #1
    P5C768 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2009
    Location
    Denver, CO
    Posts
    95

    Combo box query


    I have a field in a tbl that is numeric with 2 decimal places. I would like to create a parameter based query that can use a combo box for query options (i.e. greater than, less than, between) and a user input. For example, the user could select "greater than" and enter 2, and show all values greater than 2. Is there a way to do this?

  2. #2
    P5C768 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2009
    Location
    Denver, CO
    Posts
    95
    Any ideas? Basic question is how to use a combobox in a query.

  3. #3
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    You would have to create a form that contained a combo box with the possible options and a value text box(es) to enter the value(s). Then using vba concatenate the two to build up the query sql for your condition.

    David

  4. #4
    P5C768 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2009
    Location
    Denver, CO
    Posts
    95
    David, thanks for the response. I understand how to do most of your suggestion, but do you have any ideas on how to use the resulting concatenated string in the query?

    Would I have name the result of the combo box and textbox or could I just do something like combobox1.value & textbox1.value?

  5. #5
    P5C768 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2009
    Location
    Denver, CO
    Posts
    95
    I think I want to revise my question. Forget the combo box. When you use a parameter query, access defaults to use "equals" for matching the parameter (i.e. if you type in 2, it finds records =2).

    I need to know how to make <,<=,>,>=,<> and = inputs in the parameter query.

  6. #6
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    In the condition line if no operator is entered then Access assumes equals to, however if you preceed it with the operator it will respond to that.

    Do if you enter

    Between [Start] And [Finish] it will give you a range. Likewase if you enter
    <=[Enter a value here] it will filter out everything less than or equal to whatever you enter.

    David

  7. #7
    P5C768 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2009
    Location
    Denver, CO
    Posts
    95
    That's what I would like to get around. I am trying to figure out a way to concatenate a comparison operator and a value to work in the query, but not having much luck.

    For now, I can just use between as a substitute. I would still like to figure out a way to use >5 or <5 or whatever the user enters, because using between to get a greater than value means the use has to enter a hypothetical ceiling (i.e. between 10 and 10000, instead of just saying >10)

  8. #8
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    When you say <5 or >5

    >[Greater than]
    <[Less than]
    <=[Less than or equal to]
    >=[Greater than or equal to]
    <>[Not equal to]
    Like "*" & [Containing the string] & "*"
    Not Like "*" & [Not containing string] & "*"


    David

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

Similar Threads

  1. Replies: 2
    Last Post: 05-08-2013, 03:37 AM
  2. Open a form using a query that references a combo
    By accessbobp646 in forum Access
    Replies: 1
    Last Post: 02-22-2009, 09:50 AM
  3. Replies: 0
    Last Post: 08-17-2008, 12:19 PM
  4. How to create a query for logical combo??
    By valkyry in forum Queries
    Replies: 1
    Last Post: 10-08-2007, 02:32 PM
  5. Add combo box to parameter query
    By louisa14 in forum Queries
    Replies: 1
    Last Post: 12-10-2005, 08:38 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