default value for a combo box?

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi,

How can one make the forst entry in a combo box to become
the default value so it shows up each time a new record
to be added to the table through the data entry form?

Regards,

Mike
 
Hi Mike,

Try this in the current event of the form:

Private Sub Form_Current()
If Me.NewRecord Then
Me.Combo0 = Me.Combo0.ItemData(0)
End If
End Sub
 
Another approach without event procs....

Put this formula in the Combo0's Default Value property :

[Combo0].[ItemData](0)

which can be done using VB too like this:

frm.control("Combo0")="[Combo0].[ItemData](0)"


--
Malcolm E. Cook
Stowers Institute for Medical Research


Sandra Daigle said:
Hi Mike,

Try this in the current event of the form:

Private Sub Form_Current()
If Me.NewRecord Then
Me.Combo0 = Me.Combo0.ItemData(0)
End If
End Sub



--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Hi,

How can one make the forst entry in a combo box to become
the default value so it shows up each time a new record
to be added to the table through the data entry form?

Regards,

Mike
 
How can one make the forst entry in a combo box to become
the default value so it shows up each time a new record
to be added to the table through the data entry form?

The following method will work regardless of whether you have the combo's
columnheads turned on or not. In the form's "Open" event procedure, you can
insert the following code:

'**
Me.Combo1.DefaultValue = Me.Combo1.ItemData(Abs(Me.Combo1.ColumnHeads))
'**

You need to replace every instance of "Combo1" with the name of your combo box .
 
Back
Top