Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2008
    Posts
    25

    Want Combo-box to populate another field in same form

    Hello,

    I have a Product ID field which is a combox whose dropdown displays 2 columns (Product ID Code, Product Name) so the user can select the proper ID based on the name. When selected, only the ID Code displays and writes to the table. I would like the next textfield (Product Name) to populate automatically.

    I've tried to add the AfterUpdate on the ProdcutID field to say Me.ProductName = Me.ProductID.Column(1) but this is not working.

    Any suggestions?
    thanks!
    G

  2. #2
    Join Date
    Aug 2008
    Posts
    25
    Figured this out but thanks anyway!

    G

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    You could say what you did to fix it. What you are seeking sounds like a bad idea... I hope you "fixed" it in a way that doesn't cause you dramas later on.....
    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

  4. #4
    Join Date
    Aug 2008
    Posts
    25
    ha OK I thought I had this fixed but alas no...

    I found a way to have my combobox (ProductID) configured so that when a value is selected, it automatically fills in the associated text box (ProductName). The combobox has 2 columns of data (I used the LookupWizard to do this), and I have this code in the Source for the text box: =ProductID.Column(1) in order for the proper name to populate.

    This works fine except that the text box value is not writing to the table.

    Any ideas why?

    thanks!!

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Why: Because it is no longer bound to the field you want it to write to because you changed the source away from the fieldname.

    What to do: Restore the Control Source back to ProductName. Write a VBA script to populate the field with the combo box selection:

    Code:
    Sub ProductID_AfterUpdate()
       Me.ProductName = ProductID.Column(1)
    End Sub
    This goes in the AfterUpdate [Event Procedure] for the combo box.
    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

  6. #6
    Join Date
    Aug 2008
    Posts
    25
    Thanks StarTrekker,

    This works great for my combo boxes that have more than 1 row, however, for the DB I am building there is a need to have a form with a combobox with only 1 row (I know this is silly but the form must look EXACTLY like the PDF). I can set the default to display the correct row with setting the Default Value to [DistrictID].[ItemData](0), however, the DistrictName text field only displays when I manually re-select the DistrictID combobox (even though it is already selected at default).

    Is there a simple way to have the text field also selected at default, or if not, is there a way to the have the text field DistrictName default to the correct name?

    thanks!!

  7. #7
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Is there a simple way to have the text field also selected at default, or if not, is there a way to the have the text field DistrictName default to the correct name?
    "Simple" is subjective. Someone might find one thing simple and another person might find that same thing challenging.

    However, can't you just set the thing via the Default Value property for the text box directly... as in the text value that is the default rather than referring to the items in the combo box?
    Last edited by StarTrekker; 08-21-08 at 00:52.
    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
  •