I've seen a number of post about not opening a query if the query is blank but not sure where to have the code to check the output of the query. Before the query is run i have a number of conditions, if they are met then the query is opened. When i run the code below, the query opens and I do not get the message box.
Private Sub BetweenDates_Click()
If IsNull(Me.DateMin) Then
MsgBox "Enter starting date"
EXIT SUB
End If
If IsNull(Me.DateMax) Then
MsgBox "Enter ending date"
EXIT SUB
End If
If (Forms![2ndfrm_AddEditView]![CbCATracker1] = True) Then
DoCmd.OpenQuery "SearchCaTrackerCLUpdatedOn_Bt_qry"
end if
If DCount("*", "SearchCaTrackerCLUpdatedOn_Bt_qry") > 0 Then
MsgBox ("No records for that date range")
EXIT SUB
End If