Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2008

    Unanswered: using data from the both columns of a combo box

    In one of my forms, I have a combo box that displays a code (first column) and a name (second column) when pulled down. Naturally, it inputs the code as the bound column.

    I want to create a text box in the form, once a combo box option is selected (afterupdate I guess), I'd like the text box to display the name that corresponds to the selected code.

    The goal is to have an output that displays the code in the combo box and the name in the text box.

    One of my tables has both the code field and the equivalent name field.


    [edit] the reasoning would be.. uh, too lazy to manually input name. =D just kidding, saving a couple of mouse clicks still does wonders in the long run (especially when encoding over two years worth of data), and a computer process is far more accurate when duplicating long strings of information.
    Last edited by coffeecat; 08-11-08 at 03:17.

  2. #2
    Join Date
    Jan 2007
    Provided Answers: 10
    If it's in the combo, then you can access the value through the .Columns() collection
    Home | Blog

  3. #3
    Join Date
    Dec 2004
    Madison, WI
    To expand on George's post, you'd have a text box on your form (probably next to the combobox), set it's property to locked = Yes, Enabled = No, Tab Stop = No. And set the Source Object of the textbox to:
    = me.some_combo.Column(1)

    or in the AfterUpdate of the Combobox you could then also set the value of the text box (but you'd then need to remove the SourceObject default.)

    Keep in mind that [column](1) is really the 2nd column of the combobox (when looking at the query). To display the 3rd column of the combobox from the query, you'd use [column](2), and so on....

    Also make sure that your column count for the combobox is set to 2 (or 3 or 4, etc...depending on how many columns you have) and that you also want to make sure that a width is set in the column width property in the combobox for the 2nd, 3rd, or 4th columns (even setting it to be 0" if you don't want it displayed in the dropdown for the combobox.)
    Last edited by pkstormy; 08-11-08 at 19:48.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Jun 2008
    That worked for me. Thanks guys!

    Tab stop is new to me ("allow tabbing into control"), it means that pressing tab wont allow me to select the specified object right?

  5. #5
    Join Date
    Nov 2007
    Adelaide, South Australia
    Just means the cursor won't stop at that control. You can still mouse click in it though.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!

    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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