Results 1 to 3 of 3
  1. #1
    premis is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    33

    Combo box doesn't retrieve correct record

    I'm having some trouble with a combo box in my form. I have a database of clients, I use the combo box to retrieve a client by selecting them in the box. My problem is that if I have multiple clients with the same last name the combo box will pull the first client alphabetically by first name that share the same last name. For example, if I have 3 clients, Bob Smith, Fred Smith, and Sam Smith. If I select "Bob Smith" in the combo box it goes to the record for "Bob Smith, however, if I select either "Fred Smith" or "Sam Smith" it still goes to the record for "Bob Smith"



    Anyone know a solution for this??

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    It sounds to me like one of two things is happening:

    1. Your client table does not have a primary key
    2. If your client table DOES have a primary key you are not using that as the bound column of your combo box.

    In order for a combo box to function as a search you must have a way to uniquely identify items in the list by a SINGLE field.

    What you want to do is put the PK of your clients table (assuming you have one, autonumber field for instance) as the first column of your combo box, then you can concantenate the lastname, firstname as your second column

    Clientname: LastName & ", " & firstname

    then make the WIDTH of your first column 0 (the PK field) and the width of the second column as wide as you want (the clientname field)

  3. #3
    premis is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    33
    Quote Originally Posted by rpeare View Post
    It sounds to me like one of two things is happening:

    1. Your client table does not have a primary key
    2. If your client table DOES have a primary key you are not using that as the bound column of your combo box.

    In order for a combo box to function as a search you must have a way to uniquely identify items in the list by a SINGLE field.

    What you want to do is put the PK of your clients table (assuming you have one, autonumber field for instance) as the first column of your combo box, then you can concantenate the lastname, firstname as your second column

    Clientname: LastName & ", " & firstname

    then make the WIDTH of your first column 0 (the PK field) and the width of the second column as wide as you want (the clientname field)

    That did it!, thanks for the help!!

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

Similar Threads

  1. Replies: 4
    Last Post: 12-14-2012, 06:33 PM
  2. Replies: 1
    Last Post: 11-08-2012, 02:37 PM
  3. Combo Box NOT saving correct value
    By supracharger in forum Forms
    Replies: 8
    Last Post: 06-03-2012, 02:25 PM
  4. Combo Box not showing the correct Field
    By Atlascycle in forum Reports
    Replies: 61
    Last Post: 03-12-2012, 10:51 AM
  5. Replies: 1
    Last Post: 12-09-2011, 08:14 AM

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