PDA

View Full Version : listBox Issues



talytech
03-11-2009, 07:11 AM
On my userForm I have a listbox and a button that updates the data in a database with the data selected from the listbox. What I need to do is check what the value of the listbox is. Basically if you click the update button without making a selection I need a message box to warn that you need to make a selection. Currently an error is returned that there's a invalid use of null. My code is:
recId = ListBox1.value
MsgBox recId

How do I check for a null value or is there a way I can set the focus to the listbox?

Bob Phillips
03-11-2009, 07:14 AM
With ListBox1

If .ListIndex = -1 Then

MsgBox "Nothing selected"
Else

recId = .Value
MsgBox recId
End If
End With

talytech
03-11-2009, 07:45 AM
thank you. that worked.