Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box Display two Values 2

Status
Not open for further replies.

RachelK

Programmer
Mar 18, 2002
171
0
0
GB
Hi,

I have a combo box that displays numbers and a name which you click on the drop down, however when you select one the box only displays the number can I have the combo box display the number and name of the one selected. Cheers Rachel
 
you can have multiple columns bound to a comboBox...

so in your comboBox's RowSource property, have an sql statement that includes both the number and the name i.e.
SELECT Num, Name From...

and then make sure that the columnCount property is set to 2 and boundColum set to whichever one you wish the combobox's value to default to

Procrastinate Now!
 
Crowley16 ,
Hi again.

My Column count is set to 3 and I have the sql in the row source:

SELECT tblCourseProvider.CPID, Format([CPNO],"000") AS CPNO1, tblCourseProvider.NameLong
FROM tblCourseProvider;


The 1st column width is set to 0cm; then the other two are visible to the user however once you select a value only the 1st value displays in combo box ie:-

If you select this:-

000 Centre name

The combo box would display 000 only not the centre name as well. Any idea ? Thanks Rachel.
 
hmm, strange...

what have you set as the control source of the box?
how's about explicitly setting the width of the other 2 columns?
are you doing anything in the event procedure of the combobox?

Procrastinate Now!
 
Hi,

I have just created a combo box using the wizard. Both values show when you click the box to drop down number and Name ie

000 Name1
001 Name2
003 Name3

Once one is selected the value on the form in the combo box is just the number and this is the case with the combo wizard aswell. Cheers Rachel
 
You're referring to the "text box" part of the combo, and not the "drop down list"?

If so try, concatenate (not procrastinate;-))

[tt]SELECT tblCourseProvider.CPID, Format([CPNO],"000") AS CPNO1 & " " & tblCourseProvider.NameLong
FROM tblCourseProvider;[/tt]

Roy-Vidar
 
RoyVidar,

Thanks it worked. Cheers again Rachel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top