Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2012

    Unanswered: combo box trickery

    Hi all,

    My Name's Jim. This is my first post on this site, I'm relatively new to databases. I started learning about this stuff a few weeks ago to make a database for work. I won't go into the details if I can help it because i'm into the nitty gritty of getting the forms to look nice and do something useful. The data structure and all that are ok, I had help with that from a friend who's a pro. I can't be constantly bugging him while he's at work though so for some of the details It'd be great to get some help from you lovely folks

    My first question is about filtering a subform. Here goes..

    I have made a form which contains a subform that displays the results of a select query on one of my tables. I'd like to be able to use combo boxes to filter that subform to display certain information. If there were only one field I wanted to filter by then I believe the solution is straightforward. If I'm not mistaken you would add the combo box control as the criterion in the query the subform is based on and use the onUpdate event of the combo box to requery the subform, sound about right?

    Well, the tricky thing is that I'd like (in an ideal world) to have the freedom to filter by any of the fields. Having a combo box for each is pretty ugly but I found I can make a combo box with a field list for my query, so what I'm wondering is this..

    Can I have two combo boxes. Box1 = field list for my query. Box2 = all unique values in the field chosen by Box1. And then, filter the subform by making a select query like

    SELECT *
    FROM Query
    WHERE [Box1] (chosen field) =[Box2] (chosen value)


    Alternatively, what would be even nicer is if I could search the subform and display all records containing a given string or number in a given field. In which case you would choose the field to search in a combo box and then search that field with a txt box, displaying all the records that matched.

    Forgive me for going on, I'm just thinking out loud as it were so you know what I'm trying to do and maybe somebody has done something similar in the past.

    Any help would be appreciated.


  2. #2
    Join Date
    Aug 2004
    Cary, NC
    I don't see why not... If combo one contains the actual field names and combo two contains the actual values it should work out just fine. You would just use something like

    sql = "select * from Query where " & me.Box1 & " = '" & me.Box2  & "'"


  3. #3
    Join Date
    Jul 2012
    Thanks. Using the & signs was something I hadn't seen before, it's opened up a whole new world

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts