Acess VBA Combo box

Posted on 2011-05-02
Medium Priority
Last Modified: 2012-05-11
Following is the scenario I am dealing with...

I have the combo box with two columns

Name  Age
David 29
David 32
Peter 24
Peter 25
Peter 26
Peter 29
Maria 22
Maria 29

I selected Peter 26, and after selecting when I go back to drop down combo, it is always on Peter 24, how do I code it to have it keep the selection ie Peter 26

Question by:hitsdoshi1
LVL 120

Accepted Solution

Rey Obrero (Capricorn1) earned 1200 total points
ID: 35509112
use the Age column as the bound column or reverse the field in the rowsource of the combo box.

the duplicates names is the one causing the selected item in the combo to revert to the first of the duplicate names.
LVL 12

Assisted Solution

danishani earned 400 total points
ID: 35509118
How do you populate your Combox?
Is it an Unbound textbox, with as source your values?
Or is it bound to a Field from a Table/Query?

If its bound then it will always goes to the value stored in the table.

LVL 44

Assisted Solution

GRayL earned 400 total points
ID: 35509524
If you are using a combo box in which you are trying to assess two fields, you must make the query of the combo box a concatenation of the two fields - SELECT fName & " " & Age From People;

You can only  'Bound' to one field - but

in fact there are two.
LVL 10

Expert Comment

ID: 35512173
I'd suggest adding an ID field so each row is unique and then bind your combo box to that ID field.  It is quite possible to have two Davids who are the same age.  So using either the name or NameAge as your key is not at all reliable.

Author Closing Comment

ID: 35702519
Thank you.

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question