Empty listbox

  • Thread starter Thread starter Jean-Paul
  • Start date Start date
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
 
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
 
Back
Top