Hi all,
I'm asking for some help on this simple question. I have a form with a button that runs a query based on user's selection. Sometimes the query returns no records but leaves the query window up. The user has to manually close the window. I want to add the feature that if the query returns no records, a msgbox tells them there are no records to display and the query window closes. Would DCOUNT work here?
I'm asking for some help on this simple question. I have a form with a button that runs a query based on user's selection. Sometimes the query returns no records but leaves the query window up. The user has to manually close the window. I want to add the feature that if the query returns no records, a msgbox tells them there are no records to display and the query window closes. Would DCOUNT work here?
Code:
Private Sub btnApplyFilter_Click()
On Error GoTo Err_btnApplyFilter_Click
ColToSearch = Me.CboCol.Value
Select Case ColToSearch
Case "ID"
DoCmd.OpenQuery "IDNumberQuery", acViewNormal, acReadOnly
' DoCmd.Close acForm, "IDNumberQuery"
Case "Issue"
DoCmd.OpenQuery "Words in Issue Query", acViewNormal, acReadOnly
' DoCmd.Close acForm, "Words in Issue Query"
Case "Discussion"
DoCmd.OpenQuery "Words in Discussion Query", acViewNormal, acReadOnly
' DoCmd.Close acForm, "Words in Discussion Query"
Case "Recommendation"
DoCmd.OpenQuery "Words in Recommendation Query", acViewNormal, acReadOnly
' DoCmd.Close acForm, "Words in Recommendation Query"
End Select
Exit_BtnApplyFilter_Click:
Exit Sub
Err_btnApplyFilter_Click:
MsgBox Err.Description
Resume Exit_BtnApplyFilter_Click
End Sub