Results 1 to 3 of 3
  1. #1
    sonickidj is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    May 2014
    Posts
    1

    ComboBox How do I Autofil/autopopulatel text fields with selection of combo box

    Hi there, i'm quite a newbie at Access and i am currently stuck on a form problem. I am using a wizard of oz-style database and I want to autofill boxes through the selection in a combo box



    I already have fields in my database including charactersname, characters gender, characteridnumber etc.. and i want to include the charactersname in the combo box, so that when selecting a name, the appropriate gender is also shown below that

    In other words, if Dorothy was on the selection list/box, when selected, the gender field at the side would automatically turn to "Female", same goes for Tinman and Scarecrow being "Male"

    Thank you very much :-)

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Like this?

    BaldyWeb - Autofill
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    Does the Characters table have an ID number or other unique short field as the primary key? If not, it should, because using a character-string as your PK is (or can be) cumbersome at times, and in the case of people's names, is prone to problems with duplication.


    Now to answer your question - what you would need is some code in the after update event of the combo box, to retrieve values from the characters table and copy it to the form text boxes. The DLookup function is best used for that, and it looks something like this:

    Me![Control_Name] = DLookup("Lookup_Field","Characters","Character_ID = " & Me!ComboBox_Value)

    The names in italics would be replaced by the names you actually use in your database.

    You would use one DLookup for each form text box.

    Are the text boxes you want to fill on the form bound to table fields? They really should not be, because that results in redundant data.

    HTH

    John

    P.S. I didn't see it before posting, but the suggestion from pbaldy works just as well, and might be easier to use.
    Last edited by John_G; 05-08-2014 at 01:56 PM. Reason: additional remark

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

Similar Threads

  1. Replies: 3
    Last Post: 11-25-2013, 08:23 PM
  2. Replies: 1
    Last Post: 06-20-2013, 10:35 AM
  3. Replies: 2
    Last Post: 04-25-2013, 06:07 AM
  4. Replies: 9
    Last Post: 01-17-2013, 09:08 PM
  5. Populate a text box based on a combobox selection?
    By Richie27 in forum Programming
    Replies: 4
    Last Post: 04-25-2012, 08:00 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