Re: Printing blanks

Discussion in 'Access Macros' started by Wolfgang Badura, Sep 25, 2011.

  1. Hallo!
    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
     
    Wolfgang Badura, Sep 25, 2011
    #1
    1. Advertisements

  2. Wolfgang Badura

    mickiehick Guest

    Thanks Wolfgang

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

    Cheers
     
    mickiehick, Sep 25, 2011
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.