I've seen multiple post of closing a query if it is blank. But my code checks to see if a check box is clicked then moves to the next box. If a check box has been clicked it opens a query. I'm trying to get it to close the query then return a msgbox if the query is blank.
I get the first msgbox, but when I click other boxes I still get the messages for other boxes.
I've tried playing with ElseIf but that did not help.
I get the first msgbox, but when I click other boxes I still get the messages for other boxes.
I've tried playing with ElseIf but that did not help.
Code:
Private Sub BetweenDates_Click()
If IsNull(Me.DateMin) Then
MsgBox "Enter starting date"
End If
If IsNull(Me.DateMax) Then
MsgBox "Enter ending date"
End If
If (Forms![2ndfrm_AddEditView]![CbCATracker1] = True) Then
DoCmd.OpenQuery "SearchCaTrackerCLUpdatedOn_Bt_qry"
End If
If DCount("*", "SearchCaTrackerCLUpdatedOn_Bt_qry") < 1 Then
DoCmd.Close acQuery, "SearchCaTrackerCLUpdatedOn_Bt_qry"
MsgBox ("No records for that date range1")
End If
If (Forms![2ndfrm_AddEditView]![CbDrawing1] = True) Then
DoCmd.OpenQuery "SearchDrawingUpdatedOn_Bt_qry"
End If
If DCount("*", "SearchDrawingUpdatedOn_Bt_qry") < 1 Then
DoCmd.Close acQuery, "SearchDrawingUpdatedOn_Bt_qry"
MsgBox ("No records for that date range2")
End If
If (Forms![2ndfrm_AddEditView]![CbTool1] = True) Then
DoCmd.OpenQuery "SearchToolDeliveryDatedOn_Bt_qry"
End If
If DCount("*", "SearchToolDeliveryDatedOn_Bt_qry") < 1 Then
DoCmd.Close acQuery, "SearchToolDeliveryDatedOn_Bt_qry"
MsgBox ("No records for that date range3")
End If