Autofill Text Boxes through List or Combo box HELP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sonickidj
    New Member
    • May 2014
    • 1

    Autofill Text Boxes through List or Combo box HELP

    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, characteridnumb er 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 :-)
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    sonickidj,
    Welcome to Bytes.com.

    Perhaps the easiest way to accomplish this is to make the rowsource of your combo box have multiple columns. You can make the display length of the "extra" columns zero so they won't show in the drop-down but the data will be along for the ride.

    In the AfterUpdate event of the combo-box you can fill text boxes on the screen by referencing columns of the comobo box. Something like this:
    Code:
    me.Gender_txt = me.Character_cbo.Column(1)
    me.Age_txt = me.Character_cbo.Column(2)
    etc... Note that the first column of a combo-box is column(0).

    There are other ways to accomplish what you want but this may be the simplest. You'll find the relevant settings in the Data tab and the Format tab of the combo-box properties.

    Jim

    Comment

    • jimatqsi
      Moderator Top Contributor
      • Oct 2006
      • 1293

      #3
      For my example to work, the Select query of the combo-box rowsource would have to include Gender and Age as the 2nd and 3rd fields selected. You have complete control over that when you build the query for the rowsource.

      Jim

      Comment

      • twinnyfo
        Recognized Expert Moderator Specialist
        • Nov 2011
        • 3662

        #4
        Jim,

        Just reviewing some of these old posts, and you taught me something today! I never realized you could read the values of the various columns of the Combo Box. I thought the Value was simply the default Column.

        This gives me som ideas on how to use this new knowledge! Thanks for your post and sharing with us!

        Comment

        • jimatqsi
          Moderator Top Contributor
          • Oct 2006
          • 1293

          #5
          So glad to post something helpful once in a while :) The combo box really is a flexible, useful object.

          I've gained a strong appreciation for list boxes in recent years. I used to avoid them but now I find 101 uses for them. I've gotten more selective about when I use combo boxes.

          Jim

          Comment

          • twinnyfo
            Recognized Expert Moderator Specialist
            • Nov 2011
            • 3662

            #6
            I know this may be a bit off topic from the OP, but what advantages have you found for using a list box over a combo box? I like how compact a combo box is compared to a list box--although acombo box requires two clicks instead of one in some cases. I'd be interested to know your thoughts. I am always eager to explore new/better ways of doing things.

            Comment

            Working...