Printing certain records more than one in a report based on another value

J

jsr

I am using access 97.
I am trying to generate a report that allows you to print
a record more than once based on the value of another
field. HOWEVER, I don't want to print all records that
way. I can't figure out what is needed to allow this. Ex-
if the value of field quantity is 3, I want to print the
records twice, if quantity is 5, I print the record,
three times.

Any ideas out there?
Thanks in advance.

jsr
 
D

David Straker

The easiest way is to create a new table that has the same columns as your
current report query. Base your report on a new query against this table.
Then use the SQL syntax of your current report query as the basis for
developing code to append rows to that table just before the report runs. At
run-time:
.. delete all rows in the table, just in case the report didn't complete
properly last time
.. save the results of your new append code in the table
.. in VB code, read the table and add the extra lines that you need based on
the field value you're testing.
.. use a new report query that reads data from the new table.
.. when the report closes, delete all of the rows from the table

hth
David Straker
 
M

Marshall Barton

jsr said:
I am using access 97.
I am trying to generate a report that allows you to print
a record more than once based on the value of another
field. HOWEVER, I don't want to print all records that
way. I can't figure out what is needed to allow this. Ex-
if the value of field quantity is 3, I want to print the
records twice, if quantity is 5, I print the record,
three times.

You might(?) be able to add code to the detail section's
Format event procedure that causes the detail to be printed
multiple times. This is just air code so take it with
several grains of salt:

Dim lngDupCtr As Long
Sub Detail_Format( . . .
If lngDupCtr <= 0 Then
lngDupCtr = (Me.txtQuantity + 1) \ 2
Else
If lngDupCtr > 1 Then
Me.NextRecord = False
End If
lngDupCtr = lngDupCtr - 1
End If
End Sub

The reason I'm being wishy washy about it is that are some
situations where a page boundary split, CanGrow,
KeepTogether, etc. may throw the counting off.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top