Common question this and I've searched the archives but cant find the solution. Using the QBF to print reports with the following:
Private Sub cmdrunQry_Click()
Dim db As Database
Dim QD As QueryDef
Dim where As Variant
Set db = CurrentDb
On Error Resume Next
db.QueryDefs.Delete ("Dynamic_Query")
On Error GoTo 0
where = Null
where = where & " AND [Council]= '" + Me![Council] + "'"
where = where & " AND [Region]= '" + Me![Region] + "'"
where = where & " AND [Status]= '" + Me![Status] + "'"
where = where & " AND [StatusRevoked]= '" + Me![StatusRevoked] + "'"
Set QD = db.CreateQueryDef("Dynamic_Query", _
"Select * from tblCert " & (" where " + Mid(where, 6) & ";"))
DoCmd.OpenReport "rptList", acViewPreview, "qryDynamic_QBF"
DoCmd.ShowToolbar "MyToolBarReports", acToolbarYes
DoCmd.ShowToolbar "Print Preview", acToolbarNo
End Sub
How do I trap the "No records found" error message. I know theres code to trap it (I found it on the board) but I dont know how to place it within the above code.
Thanks
Private Sub cmdrunQry_Click()
Dim db As Database
Dim QD As QueryDef
Dim where As Variant
Set db = CurrentDb
On Error Resume Next
db.QueryDefs.Delete ("Dynamic_Query")
On Error GoTo 0
where = Null
where = where & " AND [Council]= '" + Me![Council] + "'"
where = where & " AND [Region]= '" + Me![Region] + "'"
where = where & " AND [Status]= '" + Me![Status] + "'"
where = where & " AND [StatusRevoked]= '" + Me![StatusRevoked] + "'"
Set QD = db.CreateQueryDef("Dynamic_Query", _
"Select * from tblCert " & (" where " + Mid(where, 6) & ";"))
DoCmd.OpenReport "rptList", acViewPreview, "qryDynamic_QBF"
DoCmd.ShowToolbar "MyToolBarReports", acToolbarYes
DoCmd.ShowToolbar "Print Preview", acToolbarNo
End Sub
How do I trap the "No records found" error message. I know theres code to trap it (I found it on the board) but I dont know how to place it within the above code.
Thanks