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

Form goes blank 1

Status
Not open for further replies.

lisbet

Technical User
Feb 20, 2002
9
0
0
GB
I have a form which runs off an sql query.
It has several subforms and controls.
When the query retrieves no records it goes completely blank. Both the subforms and the controls disappear. I cannot find a way to stop this from happening. Is there a way? Is there an event or state which can be referenced from which I can display an error message?
Thanks for your time
 
You could use the forms On_Load event to check for the nimber of records in the qry recordset. If >1 then close form and show msg popup.

Sorry, don't have time to write the code but you get the idea.........:-9
 
Lisbet (and Mikehoot) , not to pick nits, but before you implement Mike's suggestion (which is mostly accurate), you might alter the >1 to 0 instead:
Code:
Sub Form_load()
if Dcount("*", {your-recordsource-name-here}) = 0 then
  msgbox "Sorry, there are no records in the result set. Please try again..."
  CancelEvent
end if
End Sub

Remember, you're unique - [smile]- just like everyone else
Another free Access forum:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top