I am very new to VBA and using Access 97.
I have a form that opens and displays filtered data. The query that I am using to filter the data uses an input box to specify the data (from a field) to be displayed. I would like to have a message be displayed when there are no matching records. Right now, when there are no matching records only a blank form is displayed.
I tried to test the result of the query with:
If DCount("
", "query", "[field]") = 0 Then
MsgBox ("There are no matching records to display." & Chr(13) & Chr(10) & _
Chr(13) & Chr(10) & _
"Please make another selection.")
Exit Sub
End If
I get the following error message: The expression you entered as a query parameter produced this error: ‘The object doesn’t contain the Automation object ‘Enter_ICAO’
The field is ICAO
‘Enter ICAO’ is the prompt in the criteria section for the ICAO field in the query.
My guess is that the ‘Enter ICAO’ needs to go in the Dcount statement, I just don’t know where.
I would like to know what I am doing wrong, and if it is possible to not display a blank form if no records match the query.
Thanks for any help
I have a form that opens and displays filtered data. The query that I am using to filter the data uses an input box to specify the data (from a field) to be displayed. I would like to have a message be displayed when there are no matching records. Right now, when there are no matching records only a blank form is displayed.
I tried to test the result of the query with:
If DCount("
MsgBox ("There are no matching records to display." & Chr(13) & Chr(10) & _
Chr(13) & Chr(10) & _
"Please make another selection.")
Exit Sub
End If
I get the following error message: The expression you entered as a query parameter produced this error: ‘The object doesn’t contain the Automation object ‘Enter_ICAO’
The field is ICAO
‘Enter ICAO’ is the prompt in the criteria section for the ICAO field in the query.
My guess is that the ‘Enter ICAO’ needs to go in the Dcount statement, I just don’t know where.
I would like to know what I am doing wrong, and if it is possible to not display a blank form if no records match the query.
Thanks for any help