P
PC Datasheet
How do you create blank lines with lines to fill such reports as invoices
and purchase orders?
Thanks!
Marie
and purchase orders?
Thanks!
Marie
PC said:How do you create blank lines with lines to fill such reports as invoices
and purchase orders?
Marie said:Here's an outline of what I used ---------------
Data for my report comes from a query. The query includes the primary key
and five fields from a table.
1. Create TblBlankLine:
TblBlankLine
ARow
A1
A2
A3
A4
A5
Set ARow data type to long integer and A1 to A5 data types to match the
data types of the fields in the query. ARow is numbered 5000001 to 5000028
2. I needed a total of 28 records and blank lines in my report. Put the
following in a standard module:
Function BlankLines()
Dim Items As Integer
Items = DCount("*", "MyQuery")
BlankLines = 28 - Items
End Function
3. Union MyQuery with TblBlankLine and include the Where clause:
WHERE TblBlankLine.ARow<=(BlankLines()+5000000)
4. Put the following in the ReportHeader_Format event:
Call BlankLines
When the report opens, BlankLines is calculated. The Union query returns 28
records; whatever number of records from MyQuery and the remainder as blank
lines. Note that the fields in the report must show their borders.
Marshall Barton said:Thanks for posting back with your results. I think that's a
better approach than either of the ones I was thinking of.
Two minor questions:
1 ) Why number the blank lines way up in the 5000000 range?
That's a reasonable way if the invoice details are sorted by
their key value (row number).
2) Why do you call the BlankLines function in the Open
event? I don't see where this does anything!?
--
Marsh
MVP [MS Access]
P.S. How about fixing your From and Sig? It's kind of
confusing with all these different names.
PC said:See answers to questions below ---
ARow matches up to InvoiceID in the Union query. So the Where clause becomes
a filter both to the InvoiceDetail records that are displayed as well as the
blank records from TblBlank records that are displayed. The 5000000 range is
insurance that no InvoiceDetail records get missed. If for example ARow in
TblBlankLines was numbered 1 to 30 and the Where clause:
WHERE TblBlankLine.ARow<=(BlankLines()+0)
was used, any InvoiceDetail record with InvoiceID greater than
(BlankLines()+0) would never get printed.
The BlankLines function is called in the ReportHeader_Format event. This
calculates the value of BlankLines() used in the Where clause of the union
query.
Marshall Barton said:Continuing inline below
--
Marsh
MVP [MS Access]
PC said:See answers to questions below ---
match
the returns
28
ARow matches up to InvoiceID in the Union query. So the Where clause becomes
a filter both to the InvoiceDetail records that are displayed as well as the
blank records from TblBlank records that are displayed. The 5000000 range is
insurance that no InvoiceDetail records get missed. If for example ARow in
TblBlankLines was numbered 1 to 30 and the Where clause:
WHERE TblBlankLine.ARow<=(BlankLines()+0)
was used, any InvoiceDetail record with InvoiceID greater than
(BlankLines()+0) would never get printed.
Gotch ya.
The BlankLines function is called in the ReportHeader_Format event. This
calculates the value of BlankLines() used in the Where clause of the union
query.
But you call the function from the query, so calling it
again later doesn't affect the query.
If your invoice could possible go to more than one page and
you still need to fill out the last page, change the
function to use:
Items = DCount("*", "MyQuery") Mod 28
You came up with a nice approach here Steve and I'm glad I
stumbled into it.