selecting the default value from a List Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I input the first item of a list box to the relevant field of a
database, if the user doesn't select any other item. I want the first item to
be the default entry to the field if the user did not select anyother value.
Am I expecting too much from a simple list box?

Toyfixer
 
ToyFixer said:
How do I input the first item of a list box to the relevant field of a
database, if the user doesn't select any other item. I want the first item
to
be the default entry to the field if the user did not select anyother
value.
Am I expecting too much from a simple list box?

Toyfixer


The following code will select the first item in the list if no other item
is selected. In this example 'lstTest' is the name of the listbox.

Private Sub Form_Current()

If IsNull(Me.lstTest.Value) Then
Me.lstTest.Value = Me.lstTest.ItemData(0)
End If

End Sub
 
Hi Brendan
Thanks for the reply, but it doesn't seem to work with control source set to
the field in the table.(listbox control source set in the properties dialog
box, set to the field in the table)
Am I missing something here?

Toyfixer
 
Thanks for the reply Klatuu,

I worte the line in the After update event of the previous combo box. But it
doesn't seem to write the value to the table.

Toyfixer
 
Back
Top