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

Default value in combobox

Status
Not open for further replies.

rogerte

Programmer
Nov 9, 2001
164
GB
This is probably very easy, but haven't been able to sort it, so can someone please help?

I have done a search on this site, but cannot see it.

I am using Access 2002

The form has a combo box, which is filled from a table, no problem. However on start up the default item is blank.

The database has a second table which contains a single record that is one of the items in the first table. I would like the combobox to default to whatever item is in that second table.

Many thanks

Rog
 
Perhaps the On Load event and DlookUp? Either set the combo to:
[tt]cboCombo=DlookUp("FieldName","Table2")[/tt]
Or
[tt]cboCombo.DefaultValue=DlookUp("FieldName","Table2")[/tt]
This assumes that the lookup field is the bound column of the combo.


 
And if you just want to default to the first item then on the Default option put: (combobox is the name of your combo)

=Me![combobox].DefaultValue = Me![combobox].ItemData(0)
 
Oops. I was looking at VBA. On the Default Option you just put:

=[Me]![combo18].[ItemData](0)
 
Sorted it folks. Created a query that returned the field from table 2, used it as the default data for the form, and was then able to access it properly.

Thanks for the replies.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top