Results 1 to 4 of 4
  1. #1
    changedsoul is offline Novice
    Windows 8 Access 2007
    Join Date
    Jun 2013
    Posts
    13

    ComboBox Help


    I created a tiny database to demonstrate what is is I am having trouble understanding. Its got two tables and a form. One table Holds a list of states by name with a AutoNumber field for its PK. The other has a test field and a FK that links to the States PK.

    I made a form to test data input, made the State field a combo box hoping I could Put someone name in on the form and select the state from the combo box. When I select the state through I get an error saying the data types dont match. This makes sense to be because the States PK and the other tables FK are numbers and not text. Im sure I am not explaining it well enough. But if you take a look at the database it should become clear what I am trying to do.

    Thanks for all the help
    Attached Files Attached Files

  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,771
    The RowSource for the combobox is selecting only the state name, not the state ID. If you want to save the ID then it needs to be in the RowSource:

    SELECT State_ID, State_Name FROM State ORDER BY State_Name;

    Set other properties of combobox:

    ColumnCount - 2
    ColumnWidgths - 0";1"
    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
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You are trying to store text (First_Name) in a number field (State_ID).
    Change the query to:
    Code:
    SELECT State.State_ID, State.State_Name
    FROM State
    ORDER BY State.State_Name;
    The first field is the State_ID (the PK).
    In the properties of the combo box, click on the FORMAT tab.
    Set the COLUMN COUNT to 2
    Set the COLUMN WIDTHS to 0 (that means the width of the first field is zero (hidden) and the width of the 2nd field is auto set)

    The first field of the query (row source) is the bound (default) field. The bound field is the field that will be, by default, stored. This can be changed by clicking on the DATA tab and changing the BOUND COLUMN property.

    Also a suggestion. In every database, go to Access options and uncheck all check boxes under CURRENT DATABASE/ NAME ATUOCORRECT OPTIONS.
    (This is also known as Auto-corrupt )

  4. #4
    changedsoul is offline Novice
    Windows 8 Access 2007
    Join Date
    Jun 2013
    Posts
    13
    Awesome. Thank you both for your quick responses. This has been driving me nuts and was a big source of confusion for me when ever I tried to make a form.

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

Similar Threads

  1. Replies: 1
    Last Post: 09-06-2011, 01:47 PM
  2. Replies: 29
    Last Post: 08-16-2011, 05:52 PM
  3. Replies: 6
    Last Post: 07-28-2011, 04:07 AM
  4. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  5. Replies: 0
    Last Post: 12-16-2009, 01:14 PM

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