I have a form that displays customer sites. I have another table that tracks trouble tickets for each site and a form to display ticket history. On my main form I created a command button that opens a form and displays the ticket history for the last 12 months for the displayed site. My command button does an open form based on the site number displayed on my main form. The problem is that if a site does not have a ticket history it opens a blank Ticket History form. I want to avoid this and display a message box that displays a message "No ticket history for this site". I am thinking that I need to use an If Then statement in my command button code but I am not sure how to check the query.
This is how I have if coded now.
Private Sub cmd_TktHistoryS_Click()
If [qry_usa000_SiteTktHistory].[SiteNumber] = 0 Then
Msg = "No ticket history for this CMR#"
Else
DoCmd.OpenForm "frm_Tkt_History_Short", acNormal, , "[sitenumber]=" & [Forms]![frm_AFBSitesMain].Form![SiteNumber], , acWindowNormal
End If
End Sub