detecting listbox selection

lloydmav

Registered User.
Local time
Today, 18:04
Joined
Nov 15, 2002
Messages
75
I know this is a really simple question, but I've been away from Access for months and I feel like I've had my memory wiped!

Whats the easiest way to detect whether a selection has been made in a listbox,

I'm linking access to sql server tables which don't allow null values, to avoid nasty errors I'm adding valication to my access forms. Its easy however to forget to select a listbox!

I tried

If ListBox1.value = "" Then
MsgBox "You must select a change type"
GoTo Line1
End If

But even when there was no selection it went straight to End If

Help would be much appreciated!
:D
 
Code:
If IsNull(ListBox1) Then
   MsgBox "You must select a change type" 
   GoTo Line1 
End If
 
Try:

If Listbox1.ItemsSelected.Count=0 then
MsgBox "You must select a change type"
GoTo Line1
End If
 
I was a little late with my post. Both methods will work.
 
Cheers guys!

Seems silly now I know, I was trying things like
If List1 = Null or
If List1 = ""

Anyway Thanks
 

Users who are viewing this thread

Back
Top Bottom