selecting the first value in a list/combo box as the default

M

maxq

How do I input the first item from a list/combo box in a form if the user
doesn't select any other item? I want the first item to be the default entry
to the form field if the user did not select any other value. I'm a newbie so
if you could suggest creating expressions instead of codes, it would really
be much helpful. Please help. I'm kinda stuck in a fixed assets inventory
project.
 
C

Cheese_whiz

Hi max,

Open the form in design view. Select the combo box. Open the properties
window (f4), click on the 'data' tab, and try adding this depending on what
the rowsource is:

If you have a value list rowsource, try:

="ListItemYouWantSelected"

for example, if Green is one of the choices and you want it selected by
default, type in = "Green" in the default value.

If your rowsource is a select query, try something like this:

=[YourListBoxName].itemdata(0)

make sure to use the appropriate name to replace YourListBoxName above.

Hope that helps,
CW
 
C

Cheese_whiz

Note: I meant 'try adding this TO THE DEFAULT VALUE'

Cheese_whiz said:
Hi max,

Open the form in design view. Select the combo box. Open the properties
window (f4), click on the 'data' tab, and try adding this depending on what
the rowsource is:

If you have a value list rowsource, try:

="ListItemYouWantSelected"

for example, if Green is one of the choices and you want it selected by
default, type in = "Green" in the default value.

If your rowsource is a select query, try something like this:

=[YourListBoxName].itemdata(0)

make sure to use the appropriate name to replace YourListBoxName above.

Hope that helps,
CW

maxq said:
How do I input the first item from a list/combo box in a form if the user
doesn't select any other item? I want the first item to be the default entry
to the form field if the user did not select any other value. I'm a newbie so
if you could suggest creating expressions instead of codes, it would really
be much helpful. Please help. I'm kinda stuck in a fixed assets inventory
project.
 
S

Stu

If you put the following in the DefaultValue property
"=[NameOfComboBox].[ItemData](0) " it will give you the first value, using 0.
If you put 1 in for the index then the second value is displayed, etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top