Full Version: Cancel Form Open on No Data
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
debra_dixon
I found the code to cancel the open and it works great. However, I'm calling the form from another form and once you close the message box about the no records, the Access default msgbox is coming up about the openform event canceled. I need to stop that. I've tried turning off the warnings on both forms. Please help. Thanks.
Jack Cowley
I would use code like this in the On Click event of the button to open the form:

If DCount("*","tblNameOrQryName") = 0 Then
MsgBox "There are no records to display in the form you want to open."
Exit Sub
End If

Replace the 'tblNameOrQryName' with the name of the table or query the form you want to open is based on.

hth,
Jack
debra_dixon
Works great!! Thanks
Jack Cowley
DeDe -

You are welcome and continued success with your project...

Jack
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.