Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Printing blanks

2 views
Skip to first unread message

mickiehick

unread,
Sep 24, 2011, 11:09:43 PM9/24/11
to
I have a macro assigned to a button that prints a number of reports
based on "Due Dates". Some of these reports are often blank and I tend
to be wasting a lot of paper. Is there a way that I can print only the
reports with records shown without having to open each one first to
check? There are a total of 9 reports and they are printed daily.

Appreciate any help offered.

Wolfgang Badura

unread,
Sep 25, 2011, 6:07:37 AM9/25/11
to
Hallo!
"mickiehick" <micki...@gmail.com> schrieb im Newsbeitrag
news:85aa3b3d-49de-418b...@q4g2000yqe.googlegroups.com...

Check the Number of records of the Query or Table.

'
' Ermittelt die Recordanzahl von Tabellen oder Abfragen
' returns -1 bei Programmfehler
'
Function RecCount(ByVal Objekt As Variant) As Long
On Error GoTo RecCountErr
Dim RS As DAO.Recordset
Dim retc As Long

retc = True
If bTest Then Debug.Print "Function RecCount, Objekt=" & Objekt
Set RS = CurrentDb.OpenRecordset(Objekt, DB_OPEN_SNAPSHOT)
RS.MoveLast
retc = RS.RecordCount
EndRecCount:
On Error Resume Next
RS.Close: Set RS = Nothing
RecCount = retc
Exit Function

RecCountErr:
Resume EndRecCount
End Function

In the Macro condition you should check

RecCount("YourObject")>0

before printing.

Wolfgang


mickiehick

unread,
Sep 25, 2011, 4:16:07 PM9/25/11
to
On Sep 25, 11:07 am, "Wolfgang Badura" <WolfgangBad...@aon.at> wrote:
> Hallo!
> "mickiehick" <mickieh...@gmail.com> schrieb im Newsbeitragnews:85aa3b3d-49de-418b...@q4g2000yqe.googlegroups.com...

Thanks Wolfgang

I'll give this a try and let you know how I get on.

Cheers

0 new messages