Forum Discussion
Gilgamesh1964
Dec 04, 2025Brass Contributor
How do I reference query data from an Access Macro
I have a simple Select query that returns a number of records. In my Access macro (just for clarification, I do mean Access Macro and not VBA) I want to check how many records the query returns in a...
Dec 04, 2025
Hi,
You can use the DCount function in your macro to get the number of returned records of the query, like this:
If DCount("*","YourQueryNameHere")=0 Then
[some action here]
Non zero would of course be: >0
Depending on your regional settings, i.e. the Windows list separator, you may have to use the semicolon instead of the comma as separator in the DCount function.
Servus
Karl
****************
Access Forever News DevCon
Access-Entwickler-Konferenz AEK