Require 2 listbox selections

  • Thread starter Thread starter shmoussa
  • Start date Start date
S

shmoussa

I have 2 listboxes on my forms, list1 and list2. When both are
selected and my command button is pressed, a query is run- based on
the two selections. How can I make it so that when I click my command
button, it checks to see that selections were made in list1 and list2-
if no selection was made- I would like a popup that explains which
selection needs to be made, and then proceed on to run my query once
selections are made in both listboxes. Thanks!!
 
Hi shmoussa
If the list boxes have their multi select property set to None, use
something like this

If Len(Me.listBox1 & vbNullString) >0 Then
If Len(Me.listBox2 & vbNullString) >0 Then
'code here to run the query
Else
'call the msgbox
End If
End If


If the list boxes have multi select turned on, you use ItemsSelected to see
if the user has chosen anything.

If Me.listBox1.ItemsSelected.Count > 0 Then
If Me.listBox2.ItemsSelected.Count > 0 Then
'code here to run the query
Else
'call the msgbox
End If
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Back
Top