I have a button on a form that tests for records, by running a select query, before opening another form. (See below)
Could someone be kind enough and show me how to combine the query into the code behind the button so that I could get rid of Qry_test altogether.
Code behind the button:
If DCount("*", "Qry_test") < 1 Then
MsgBox "There are no cases awaiting allocation", vbOKOnly
Else
DoCmd.OpenForm "Frm_AllocateMain"
End If
SQL view from the select query (Qry_test)
SELECT Tbl_Referral.Caseworker
FROM Tbl_Referral
WHERE (((Tbl_Referral.Caseworker) Is Null) AND ((Tbl_Referral.SiteName)=[Forms]![Frm_MMenu]![CmbSite])) OR (((Tbl_Referral.Caseworker) Is Null) AND (([Forms]![Frm_MMenu]![CmbSite]) Is Null));
Many thanks in advance
Could someone be kind enough and show me how to combine the query into the code behind the button so that I could get rid of Qry_test altogether.
Code behind the button:
If DCount("*", "Qry_test") < 1 Then
MsgBox "There are no cases awaiting allocation", vbOKOnly
Else
DoCmd.OpenForm "Frm_AllocateMain"
End If
SQL view from the select query (Qry_test)
SELECT Tbl_Referral.Caseworker
FROM Tbl_Referral
WHERE (((Tbl_Referral.Caseworker) Is Null) AND ((Tbl_Referral.SiteName)=[Forms]![Frm_MMenu]![CmbSite])) OR (((Tbl_Referral.Caseworker) Is Null) AND (([Forms]![Frm_MMenu]![CmbSite]) Is Null));
Many thanks in advance