Controlling Errors

Dominato

Registered User.
Local time
Today, 17:13
Joined
Apr 10, 2002
Messages
19
Here's my issue. I wrote VBA code that does a couple calculations for me. It works fine (I should mention this is in a form). The form is based off a query. The query asks for the user to input a date. If the date returns any results, everything works fine. However, if the date returns no records, I get a VBA error opening the form because I reference something that has no value. How can I get it to just popup an alert that no records were found then stop before opening the form? Any suggestions are appreciated. I can elaborate more if necessary. Thanks.
 
On Open Event
With CodeContextObject
If (.RecordsetClone.RecordCount = 0) Then
DoCmd.Close
Beep
MsgBox "There are no records for this period.Please check the dates you have entered.", vbOKOnly, "No Records"

End If
End With
 
Form Open Event

If Me.RecordSet.RecordCount<1 then
Cancel=True
Msgbox "Your Message"
Exit Sub
End If

[This message has been edited by Travis (edited 04-12-2002).]
 

Users who are viewing this thread

Back
Top Bottom