Printing serial numbers in report (1 Viewer)

cars77

New member
Local time
Today, 00:52
Joined
Nov 21, 2013
Messages
2
Hi,

I have a table that has a field for SerialNumberStart and QtyRequired, from those two I have a calculated field for the SerialNumberEnd.

I want to print a report from this table that if for example I have StartSerialNumber 34 and SerialNumberEnd 40 prints one report for each serial number

Any ideas?

Regards,
Sofia
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:52
Joined
Feb 19, 2013
Messages
16,610
I don't know why MS have provided a calculated field but I wouldn't use them - you should calculate every time you need to.

I don't understand your table, you have one record but you want to produce x number of reports from this table based on the quantity required, from what you have said, the only thing that would change is the serial number - is this correct?
 

cars77

New member
Local time
Today, 00:52
Joined
Nov 21, 2013
Messages
2
Hi CJ,

Thanks for your response

I have a Serial Number textbox in the report that takes the data of the SerialNumberStart on my table.

Regardless of the 'calculated field' in my table I would like to print the quantity required of this report, so If I need 5 'copies' of the report I want to print each copy with a different serial number starting with whatever number I have on the SerialNumberStart.

As an example, in the attached file first row, I would like to print my report twice - as ReqQty = 2 - with my serial number text box for the first report = 23 and the second one = 24

Regards,
Sofia.
 

Attachments

  • crcexample.JPG
    crcexample.JPG
    21.2 KB · Views: 125

CJ_London

Super Moderator
Staff member
Local time
Today, 00:52
Joined
Feb 19, 2013
Messages
16,610
OK, you will need to do this in VBA in a print button click event, we'll call it btnPrint.

Code:
Private Sub btnPrint_Click()
dim i as integer
 
    For i=serialnostart to serialnostart+reqqty-1
        docmd.OpenReport "myReport",,,,,i
    next i
 
End Sub

i is passed as an opening argument so in your report open event you will need to assign it to an unbound control which displays the serial number.

you may need to change the other parameters of openreport to print etc.
 

cjrhoads

Registered User.
Local time
Yesterday, 19:52
Joined
Nov 27, 2013
Messages
14
Can't you also just create a query with a parameter field that asks for the starting number, and then increment that number in another calculated field in the query and then print that on the report? That's the way I would do it. Then you wouldn't need programming.
 

Users who are viewing this thread

Top Bottom