Results 1 to 6 of 6
  1. #1
    rscott7706 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Location
    Lakeside Ca
    Posts
    24

    Populate a field based on combobox selection

    I would like to populate a (another) table field based on user combo box selections.



    I would like a combo box with selections A, B, C, D, E, etc.

    If combo box A is selected, it would populate with the numeral 1; if B were selected, it would populate with the numeral 2; if C were selected, it would populate with the numeral 3; etc.

    So, we would have a combo box in the form, but it would not populate a table field with the combo box selections, but with values driven by the combo box selections.

    Is this possible?

    Ron

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    yes; the combobox (all active controls) has an 'AfterUpdate' event. You would put in vb code that would perform this task.

    the vanilla way that Access provides novices to this is a different approach - their path is to set up a 'lookup' field at the table level.

    However in your case you are wanting to do a translation from A to 1 - and so one must put in a little VB.

  3. #3
    rscott7706 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Location
    Lakeside Ca
    Posts
    24
    Quote Originally Posted by NTC View Post
    yes; the combobox (all active controls) has an 'AfterUpdate' event. You would put in vb code that would perform this task.

    the vanilla way that Access provides novices to this is a different approach - their path is to set up a 'lookup' field at the table level.

    However in your case you are wanting to do a translation from A to 1 - and so one must put in a little VB.
    Thanks for your quick reply. I think the lookup table approach is best for me (no VB skills).

    The task is actually to set membership levels for a Chamber of Commerce. So, my example simplified this - Associate = $X, Business = $X

    So I would build a table of amounts, then in the combo box how would I reference the lookup? (I hope I am on the right track)


    Ron

  4. #4
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    Well anyone designing a database needs a textbook. So be sure to purchase one in the version you are using, easily found at Amazon or any big box bookstore. Any textbook is going to cover setting up a lookup field in a table.

    The one additional hint to add about this is that Access likes to default the 'bound' column as the first column. So if your look up is of a table and you view: Title $

    It will default to putting in (bound) the Title.

    If your look up table has an autonumber key so that it is this:

    Key Title $

    It is going to want to enter the Key.

    One can change that after the fact - in the property of the lookup field...or be sure to set your look up table like this: $ Title

    and then it will enter the $ value into the field...

  5. #5
    greenlydon is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1
    I am using Access 2010

    I have a form (enter customer information). I have a customer table, state table, city table, and zip code table.

    On the form I have a state combo box and a city combo box. I want to select the state and from that selection I want the city combo box to be populated with all the cities from the state that was selected from the state combo box.

    I have a query that the following code has been entered into it:

    SELECT CityTbl.CityName, CityTbl.CityStateName, StatesTbl.StateName
    FROM [StatesTbl].StateName
    WHERE StateName = cboState;

    When I select the state the city is not being populated.

    In advanced, Thank you for you any help given.

  6. #6
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    A combobox contains data that is valid when the form is opened.

    Therefore when you select a State; you must force the City combobox to requery.

    Hope this helps.

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

Similar Threads

  1. Populate one field based upon another fields data
    By BigBrownBear in forum Queries
    Replies: 1
    Last Post: 03-23-2010, 04:27 PM
  2. Replies: 0
    Last Post: 12-16-2009, 01:14 PM
  3. Replies: 3
    Last Post: 10-05-2009, 07:22 AM
  4. Replies: 1
    Last Post: 08-14-2009, 08:41 AM
  5. Replies: 0
    Last Post: 04-17-2008, 09:24 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