Results 1 to 10 of 10
  1. #1
    JSHEL is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    8

    Text box to populate from combo box selection

    This is probably really simple but it's driving me crazy.
    The facts.
    one table. fields are [Sitename] and [address]
    On the form I have a combo box with a row source of [Sitename]
    and a txt box that I want to show the corresponding address of the sitename afterupdate.
    I have tried a few different ways and nothing works I even tried the sync of combo boxs tutorial but that pulls from two different tables and i can't seem to make it work with one. let alone a txt box.
    thanks for the help.




    Jshel

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The simplest way would be to add the address field to the combo row source, then have a textbox with a control source of:

    =ComboName.Column(1)

    The column property is zero based, so 1 is the second column.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    JSHEL is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    8
    I knew it must have been something really simple. lol
    Thanks a ton.
    Jshel

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help, and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    JSHEL is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    8
    Ok i guess i'm going to drag this out a bit more. The suggestion below works great for displaying the information but i also need it to save to the table. is there something i can add to the control source to preform both functions?

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You probably shouldn't, but this type of thing in the after update event of the combo:

    Me.BoundTextboxName = Me.ComboName.Column(1)

    where BoundTextboxName is the name of a textbox bound to the field you want it saved to.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    JSHEL is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    8
    Why shouldn't I use this afterupdate command? I guess what i'm asking is what are the pro's and con's. And is there a better way to accomplish what i'm trying.

    Thank you for your time.

    Jshel

  8. #8
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I meant you generally shouldn't store related data. Typically you only store the key value in related tables (let's say employee number), and you get the related information (employee name, address, etc) by joining the employee table to the related table in a query.

    No problem at all using the after update event.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    jmitchelldueck is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    51
    Would there ever be any situation in which it is beneficial to store the auto-populated text box in the same table as the data you are selecting from? Or does a query work the best?

    Thanks.

  10. #10
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Sometimes it's appropriate. If I'm picking a part number for an invoice and the auto populated text is the price for that part, it makes sense to save the price with the invoice, as the price in the parts table will change over time.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Populate a field based on combobox selection
    By rscott7706 in forum Access
    Replies: 5
    Last Post: 06-02-2011, 03:18 PM
  2. Replies: 3
    Last Post: 05-25-2010, 02:16 PM
  3. Use a combo box to populate a text field
    By niesenj in forum Forms
    Replies: 2
    Last Post: 01-29-2010, 01:57 PM
  4. Replies: 1
    Last Post: 08-26-2009, 10:45 AM
  5. Replies: 3
    Last Post: 02-26-2009, 10:17 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