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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message box for no records returned in list box? 3

Status
Not open for further replies.

HenryAnthony

Technical User
Feb 14, 2001
358
US
Through the gracious help from this forum, I have gotten my form based on a parameter query, which gets parameters from combo boxes on the form, to work! Then, by clicking on a record shown in a list box, I can show more detailed info about the record. YES!

Now I need some suggestions on how to pop a message box when no records are found. I am trying to use the ListCount property of the list box to no avail. Should I be triggering this from the afterupdate event?

Thank you all very much and best regards,

Henr¥
 
In the event that triggers your record to show (AfterUpdate) run a DCount before the code to determine if records exist, and if they don't then pop the msgbox. Something like this:

[tt]
If Dcount(&quot;[UniqueID]&quot;,&quot;MyQuery&quot;) < 1 Then
MsgBox &quot;No Records To Show!&quot;
Exit Sub
End If
[/tt]

HTH
Joe Miller
joe.miller@flotech.net
 
Hi!
Yes, you can use ListCount for check of records on list box.

If Column Head of list box is set Yes then:

If me.lstList.ListCount <= 1 Then
MsgBox &quot;There aren't records for display!&quot;
End If

If Column Head of list box is set No then:

If me.lstList.ListCount <= 0 Then
MsgBox &quot;There aren't records for display!&quot;
End If

Also you can use Visible property - I think it's better solution:

me.lstList.Visible = me.lstList.ListCount > 1 'or >0

Aivars



 
Thank you both for your responses. I will explore each suggestion. I understand Joe's method but am not too sure about using the visible property. How does the lack of records affect the visible property?

Best regards,

Henr¥
 
You guys definitely ROCK!

Got it to work. This was a lot simpler than I thought.

Best regards,

Henr¥
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top