Listbox values

rmacleod

Registered User.
Local time
Today, 15:24
Joined
Apr 7, 2004
Messages
21
How would I make it so that a List box defaults to the first value available in its list?

I need to be able to make a Calculation based on the value in the listbox...but by default no value is selected. So my calculation does not work until the value is selected.
 
Code:
Private Sub Form_Open(Cancel As Integer)

  Me.ListBoxName.Selected(0) = True

End Sub
 
thanks,
but when I use that and open the form it seems to lock things up. I can not do anything in the form. It wont let me select any other controls on the form.
 
Me!ListBoxName.Selected(0) = True

???
 
Curious, as it works fine on my PC (A2k). Can you post a sample db?
 
Looks like it does lock up the Form in A97 at least when using the Form_Open event.

Seems to work OK in the Form_Load event but referencing the value required specifying the Column even if there is only one column.

This works and Column is required to referencing the value.
Code:
Private Sub Form_Load()

    Me.ListBoxName.Selected(0) = True
    Me.txtMyTextBox = Me.ListBoxName.Column(0)
    
End Sub

Thereafter the column is not required to reference a single column List Box.
Code:
Private Sub ListBoxName_Click()

    Me.txtMyTextBox = Me.ListBoxName
    
End Sub
Might be just an A97 thing???

Regards,
Chris.
 
Actually it is happening for me in Access2k3.

I will try it in the load form event instead.
 

Users who are viewing this thread

Back
Top Bottom