How to set a default value on a combo box

ShanVel

ShanMug
Local time
Today, 13:47
Joined
Oct 12, 2005
Messages
51
Hi all,

Can some one help me with how to set a default text on a combo box whose record source is set to a query?

I have a form with two combo boxes. The first combo box’s record source is set to the following query:

SELECT chrCategoryID, chrCategoryName
FROM tblGuarCategory;

My 2nd combo box will list all the items based the category I select on the first combo box.

But when the user opens the form, instead of showing both combo boxes blank, I would like to display the following text:

Combo Box1: Select a category
Combo Box2: Select an item…


I tried to use the combo box’s Default Value property like = “Select a category”. It didn’t work. I am not sure what is missing here. I appreciate your help.
 
Set Event when Open Form
Code:
Me.combo1.Value="Select a category"
Me.combo2.Value="Select an item…"

:o;)
 
Dear Clerics,

Thanks for the tips. I tested your code but still didn't work.
 
I guess it's because it's a integer field which holds the data, so you cant set text as a value. I have done some testing and didn't find an option to display what you want, but I do understand what you mean

you can try to work around it a textbox on top of it with the text you want and code in the on mousedown action making the cmb box visible and set the focus to it and hiding the textbox.

anyway, if someone knows the option, now i can read it too :)
 
I found a solution for this. This will work for instances when there are more than 1 column in the rowsource. the trick is to set the rowsource, and then set the value. Here's an example

With Me.combo1
.ColumnCount = 2
.ColumnWidths = "0;1"
.BoundColumn = 1
.RowSource = "SELECT MyTable.[Primary Key], MyTable.Value FROM MyTableWHERE (((MyTable.[Primary Key])=7075));"
.Value = 7075
End With
 

Users who are viewing this thread

Back
Top Bottom