So I've got a search form that populates the expressions in a search query and then opens a form which displays the results of the search query. If the search criteria returns a null set in the query, I would like to display a dialog box that says "Your search returned no results." So i added the following code in the OnLoad event in the form which displays the query results:
If Form!ClaimID = "" Then MsgBox "Your search returned no results"
I get the following error message:
Runtime Error 2427
You entered an expression that has no value.
Yes, I know it has no value, that's why I want a dialog box to tell the user that in a nice way... Any clues?
And for a similar idea here is something I sometimes put in code behind the form of a form's FormLoad property:
' Check for no recs (i.e. if cur rec is new rec) and if so then msg.
If Me.NewRecord Then
MsgBox "No records matched the criteria." & Chr(13) & Chr(10) & Chr(10) & "You may continue with the new record or else close the form.", vbExclamation