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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

basic combobox question default value

Status
Not open for further replies.

jebushatescats

IS-IT--Management
Jun 6, 2006
37
0
0
CA
Hello all

I have a combobox that uses a stored procedure as it's recordsource.
No problems with this in that the combobox is populated with the correct data. By default the comboxbox does not show a value until you click on the dropdown arrow.Is there a way of setting the first value of the recordsource to show without having to click on the dropdown arrow?
 
You can use, say, the Current event to set the combo box equal to the first value in the bound column:

[tt]Me.cboCombo=1[/tt]
 
Or if you don't know the specific values in the combo, then this:
Code:
cmbCombo = cmbCombo.itemdata(0)

displays the first item in the combo.

ATB

Darrylle





Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 

Why not set a default value in the properties box?


Randy
 
Hi randy,

You can try my suggestion as above in <Default Value>, but this property doesn't seem to have any effect in '97 or 2000.

ATB

Darrylle

Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 

In my version of Access (2003), I simply set a default value in the properties box....
Default value [COLOR=red yellow]4[/color]

This with a row source something like...
Code:
SELECT ID, Name FROM myTable

I have 2 columns, widths are 0;1.
Bound column is 0.

When I open the form, the combo box is populated with the name associated with an ID of 4.


Randy
 
randy,

And if your combo is populated from a table, where the record of ID of 4 can be deleted - what happens then?

ATB

Darrylle



Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 

When I use default values, I use the value that is most common for that particular field, which makes the chance of it being deleted negligible.

If that value were to be deleted at some point, the form would no longer display a default value and I'd have to make a correction - or simply continue without it.


Randy
 
Hello everybody!, Darrylles

I go my self a very similar question and I hope is no problem to post that here. After reviewing the posts I feel that I'm very close to my expected result.
I use a combo box to find data entry's from the table.
When I enter a value not in the table I get a message: "The text you entered isn't an item in the list" and the drop down arrow pulls down automatically and shows me what I have in the table.
When I type in a data from the table, dropdown arrow don't pulls down automatically and if I hit enter or arrows, the drop down still inactive.
How can I have that when I enter a data from the table the drop down to automatically be set to the value I typed? I tried “cmbCombo = cmbCombo.itemdata(0)” but when I open the form I get #Name?

TIA


Cristian
 
Set the AutoExpand property of the combo to True.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hello!

I do have that set to yes (I have options Yes or No)

C
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top