Empty listbox

J

Jean-Paul

Hi,
I have a form with 2 listboxes.
The value of listbox2 is based upon what the user has chosen in listbox1

Sometimes no matching values are found so the listbox remains empty

this is the code

Dim sql As String
sql = "SELECT Sub_doel.Hoofddoel, Sub_doel.Sub_doel,
Sub_doel.Omschrijving FROM Sub_doel WHERE Sub_doel.Hoofddoel= " &
Forms!Doelstellingen!Keuzelijst0 & " ORDER BY Sub_doel.Sub_doel;"
Me!Keuzelijst2.RowSource = sql

Question.

When the listbox is empty I want it to be invisible

How can I check if listbox2 is empty or not (in other words, if matching
records ar found or not.

Thanks
 
D

Dirk Goldgar

Jean-Paul said:
Hi,
I have a form with 2 listboxes.
The value of listbox2 is based upon what the user has chosen in listbox1

Sometimes no matching values are found so the listbox remains empty

this is the code

Dim sql As String
sql = "SELECT Sub_doel.Hoofddoel, Sub_doel.Sub_doel, Sub_doel.Omschrijving
FROM Sub_doel WHERE Sub_doel.Hoofddoel= " &
Forms!Doelstellingen!Keuzelijst0 & " ORDER BY Sub_doel.Sub_doel;"
Me!Keuzelijst2.RowSource = sql

Question.

When the listbox is empty I want it to be invisible

How can I check if listbox2 is empty or not (in other words, if matching
records ar found or not.


With Me!Keuzelijst2
.Visible = (.ListCount > 0)
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

depending listboxes 7
how to work with all items in a listbox 1
Listbox questions 2
check if any item selected on listbox 1
empty listbox 1
Cascading list box 1
weird listbox behavior 9
Listbox Default Record 1

Top