Reply to comment

MS Access: A Hack to Print Blank Rows in a Report

This is a way to insert empty or empty-like rows into a list of "seats" that contains not only reservations, but a number saying how many seats a group of people have. If the number is greater than the number of seats, this adds new blank rows for empty seats.

Sub insertBlankRows()
    Dim dbs As Database, qdf As QueryDef, strSQL As String
    Dim rst As Recordset
    Set dbs = CurrentDb
    strSQL = "SELECT tblSeats.OrganizationId, [MaxOfSeats]-Count([OrganizationId]) AS Difference, " & _
            " Count(tblSeats.OrganizationId) AS CountOfOrganizationId, Max(tblSeats.Seats) AS MaxOfSeats " & _
            " FROM tblSeats GROUP BY tblSeats.OrganizationId;"
    Set rst = dbs.OpenRecordset("qryDifferences", dbOpenForwardOnly)
    While (Not rst.EOF)
        For i = 1 To rst!Difference
            insSQL = "INSERT into tblSeats (OrganizationID, LastName, FirstName) VALUES (" _
                & rst!OrganizationId & ", '', '')"
            ' MsgBox (insSQL)
            dbs.Execute (insSQL)

End Sub

emptyrows.jpg90.86 KB


The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.

More information about formatting options

4 + 15 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.