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

Setting default in combo box to first value in list

Status
Not open for further replies.

stupiet

Programmer
Aug 21, 2001
176
US
To anyone who can help,

I have a combo box that populates names based on the department.
One thing I want the combo box to do is to select the first person in that list when the form opens. Instead it shows blank until you select a person. Is there a way to do this? I know you can do it in a listbox by using:
Me!Listbox.Selected(1) = True
Is there a simple way to do this for the combo box also?

Thanks
 
If the value you want is always the same then in the Default Value property, just add that value on the property line
For example:
="apples"

That value will always show in the Combo box in a new record.

Paul

 
Lots of times, the underlying box is based on a table. If it is, you can simply use a Dlookup function to set the value in the form's Load Event.

Me.MyComboBox = DLookup("[THIS_FIELD]","IN_THIS_TABLE",[THIS_FIELD] is not null")

You can also experiment with DMin("[FIELD_NAME]","TABLE_NAME","[FIELD_NAME] is not null") or DMax.

Hope this helps. FYI: DLookup and such are lightning fast.

Alan J. Volkert
Fleet Services
GE Commercial Finance Capital Solutions
(World's longest company title)
Eden Prairie, MN
 
Thanks Paul & Alan,

Alan, I tried your first method and it works great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top