Results 1 to 3 of 3
  1. #1
    Join Date
    May 2010

    Unanswered: Auto Fill Text Fields Based on Combo Box

    Okay, I am a complete noob when it comes to VBA and Access so please take it easy!

    I'm trying to fill in a few text boxes with information based on a selection from a combo box. I have been searching for examples the past week and have gotten nowhere.

    I'll try to explain what I'm looking for as best I can.

    I have these text boxes;
    City, State, Country and SiteID

    I also have the corresponding combo boxes.

    I am looking to pull data from my "MAIN" table with the columns "CITY, STATE, COUNTRY, SITEID".

    If the combo box for "city" is changed to... "Detroit" I would like it to auto fill "Country, State and SiteID" into the corresponding text boxes from my table.

    How can I do this?

    I attached a screenshot that may help.
    Attached Thumbnails Attached Thumbnails queues.bmp  

  2. #2
    Join Date
    Jan 2009
    Kerala, India

    Auto Fill Text Fields Based on Combo Box

    You can create a single Combox using the base table with all the required values in different Columns, SiteID as the first Column and Control Source can be the SiteID field on the Form.

    When you click on a line in the Combobox to select the SiteId, the Click-Event can run a VBA Routine to extract other values from the Combox in different columns on the same line of the SiteId selected and insert them into their respective fields on the Form.

    Take a look at the following link for an example with VBA Code:

    LEARN MS-ACCESS TIPS AND TRICKS Blog Archive Combo-Box Column Values (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

  3. #3
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    Set up your combobox using the wizard and include the fields you need, from Left-to-Right.

    If in the Combobox they appear as


    the code would be

    Private Sub YourComboBoxName_AfterUpdate()
       Me.txtCity =  Me.YourComboBoxName.Column(0)
       Me.txtState = Me.YourComboBoxName.Column(1)
       Me.txtCountry = Me.YourComboBoxName.Column(2)
       Me.txtSiteID = Me.YourComboBoxName.Column(3)
    End Sub
    Notice that the column index is zero based.
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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