Jo:
You can make the macro actions conditional, so you can call the DCount
function to check if the query returns any rows and only pop up the message
box and open the query if the function returns a value greater than zero.
You could also pop up a different message if it returns zero rows if you
wished. If the Condition column isn't showing in the macro designer select
Conditions from the View menu. You'll need a condition for each action so it
would look something like this in design view:
Condition Action
DCount("*","YourQueryName")>0 MsgBox
DCount("*","YourQueryName")>0 OpenQuery
DCount("*","YourQueryName")=0 MsgBox
The first message box would be your "Checking for overdue items." message,
the second one, if you use it, something like "No overdue items found.".
Alternatively you could do the same in code either in the Click event
procedure of the button which opens the form, or in the form's Open event
procedure:
If DCount("*","YourQueryName")>0 Then
MsgBox "Checking for overdue items.", vbInformation, "Overdue Items
Check"
DoCmd.OpenQuery "YourQueryName"
Else
MsgBox ""No overdue items found.", vbInformation, "Overdue Items Check"
End If
Ken Sheridan
Stafford, England
Hi ken, I have put a macro to open the query when they click on a button that
open the form. This works good including a msg to say "checking for
overdue....". But my problem now is solving the problem when there are no
overdue items. I have tried putting a macro in the On No data event but not
sure what to put there? Can you please help?
Jo
[quoted text clipped - 15 lines]
Please help if you can
Jo