Results 1 to 5 of 5
  1. #1
    kem is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2013
    Location
    Sault Ste. Marie, Michigan
    Posts
    5

    combo box returns value from wrong column

    I'm not exactly new self-taught, my apologies for not using "proper" titles.


    In Access 2003, trying to use a combo box on a form to enter a value from table A column 2 into column table B column 5. everything looks right except that the value from column 1 of table A shows in column 5 of table B. How do I specify that the combo box should return the value from column A2 instead A1?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What is A 1 - a unique ID field? Is this the primary key of table A? If you don't want the primary key saved as foreign key, why does the field exist?

    Show combobox properties:

    RowSource
    BoundColumn
    ColumnCount
    ColumnWidths

    What data type is B 5?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    WarrenG is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    6
    Try click on the properties for that field. Go to the Data Tab and copy and cut what is in the Row Source (ctrl X) and paste somewhere in case you want to paste it back in. Click on the 3 dots to bring up the query window. You should see the table that your Form is bound to. There should be no fields selected if you cut the Row Source expression. Now simply add the one field that you want that combo box to look at. That should do it.

    I actually just learned how to do it this way while making a Web Database Form for the first time, None of the Wizards were popping up for me to assign the table and field to the combo box.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Here's a general example of assigning values from a Combobox to Textboxes. If, in the Row Source for the Combobox they appear, reading left-to-right, as

    Field1 | Field2 | Field3

    Then this code will assign them to corresponding Textboxes on the Form:

    Code:
    Private Sub YourComboBox_AfterUpdate()
       Me.txtField1 = Me.YourComboBox.Column(0)
       Me.txtField2 = Me.YourComboBox.Column(1)
       Me.txtField3 = Me.YourComboBox.Column(2)
    End Sub

    Note that the column index is Zero-based, so the first field is 0, the second field is 1 and so forth.

    Also be sure that the number of fields you see, when the values are dropped down, are the same as the Column Count (Properties - Format - Column Count.) If the Combobox was made with a Wizard the PK field may not be visible.

    Linq ;0)>

  5. #5
    kem is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2013
    Location
    Sault Ste. Marie, Michigan
    Posts
    5
    Issue resolved, at least for me.

    I received the email update notice late yesterday and apologize for not getting back sooner. Certainly appreciate the help offered. Yes, A1 was originally the primary key but I switched that back-and-forth and also changed the order of the columns and attempted total re-creation of the drop-down box using the wizard.

    Also messed with combo box properties but didn't know how to add information beyond what the wizard offered(didn't see an option to specify the column). I knew that someone would give me the exact code, unfortunately I am severely limited with regard to understanding code other than cut and paste.

    I finally broke down last night, before reading your comments and fed the combo box drop-down directly, using the "I will type in the values that I want" choice. Of course, this would not work for issues that totally required reference to another table. Again, thanks for the help. I'm sure others with similar issues and backgrounds will benefit.

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

Similar Threads

  1. Replies: 7
    Last Post: 05-21-2014, 02:55 PM
  2. Replies: 5
    Last Post: 11-01-2013, 10:34 AM
  3. Replies: 2
    Last Post: 01-11-2013, 06:51 PM
  4. Replies: 2
    Last Post: 04-10-2012, 12:30 AM
  5. Replies: 4
    Last Post: 02-22-2012, 12:43 PM

Tags for this Thread

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