On Sep 25, 11:07*am, "Wolfgang Badura" <WolfgangBad...@aon.at> wrote:
> Hallo!
> "mickiehick" <mickieh...@gmail.com> schrieb im Newsbeitragnews:85aa3b3d-49de-418b-b3db-(E-Mail Removed)...
>
> >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.
>
> 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
Thanks Wolfgang
I'll give this a try and let you know how I get on.
Cheers
|