Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to tell Access to check if Listbox is populated and then carry out

Status
Not open for further replies.

KennyUK

Technical User
Sep 13, 2001
38
GB
Hello,

I have a problem and I wondered if the experts of this group could help me out.

I have a list box on a form that to simple, I will call "List1" and the form is called "frm1".

I would like to tell Access to check if the list box has any data in it and if so then perform Task A
but if not perform Task B.

Can anyone tell me the correct method or syntax for doing this as I can not seem to get it right.

Thank you in advance,

Kimi.
 
If You want to check the list from another place that the Class Module of frm1 then:

If Forms("frm1").Controls("List1").ListCount > 0 Then
<TASK A>
Else
<TASK B>
End If
or
If Forms(&quot;frm1&quot;).List1.ListCount > 0 Then
<TASK A>
Else
<TASK B>
End If

If You check it from whitin the frm1's Class Module:
If Me.List1.ListCount > 0 Then
....
Else
....
End If

Beware, in the first situation You have to have the frm1 open.

Tibi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top