Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    42

    Unanswered: Add "*" to Combo Box

    I'm looking for a way to add a wildcard ("*") to the top of a combo box. The other options that the user can select are taken from a table.

    For example, I have a table of cars with three columns: Make, Year, and Model. On a form, I want two seperate combo boxes and a list box. The two combo boxes should be Make and Year, and the list should be Models. If I select Toyota and 1998 from the list boxes, I only want to see those models that are a toyota from 1998 in the list. If I select Toyota and *, I want to see all models that are toyotas, regardless of year. The combo boxes will pull in available makes and years from my table, but I need to know how to add the "*" to the beginning of each of their lists.

    Thanks for any help

  2. #2
    Join Date
    Nov 2003
    Location
    San Francisco, CA USA
    Posts
    59
    I suppose you could create a union query and add the asterisk as a string constant to the dataset you draw.

    I am pretty sure you have to do this in the SQL view rather than Design View of the Query window.

    I'll post an example shortly if I remember.

    Magee

  3. #3
    Join Date
    Nov 2003
    Location
    San Francisco, CA USA
    Posts
    59

    It's kind of crude but it works

    SELECT tblPurposeOfProduct.PurposeID,
    tblPurposeOfProduct.PurposeOfProduct
    FROM tblPurposeOfProduct
    UNION
    SELECT "dummyID" as PurposeID, "*" As PurposeOfProduct
    FROM tblPurposeOfProduct;

    Apparently Access doesn't care when it pulls data out of tables about data type conflicts. PurposeID is an autonumber (long) and as you can see "dummyID" is a string.

    You'd have to pick some flag for your ID fields if you are using multi-column combo boxes. Since you're using it to drive code, rather than update tables, I think this is fine. Otherwise, you'd run into trouble if you had a Control Source specified for your box and it had a hidden primary key column expecting long values as a bases for pulling/updating/displaying recordset data.

    Good luck!

    Magee

  4. #4
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    Or if you just want to keep things simple and have the * show up immediately but not necessarily be in the list just set the DefaultValue to be the asterisk.
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

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