Solved ** Print multiple up labels with variable label count

Rocky E

Board Regular
Joined
Feb 20, 2002
Messages
105
I am trying to print some labels for shipping containers. The query produces the total quantity of the order, the quantity per container and a calculated field figurers the number of containers. Labels are 4-up on a sheet. I could leave some blanks in between orders that didn't come up even, but would rather not. Right now I have a command button on a form, but I can't figure how to get it to multiple copies, let alone vary the number of copies with each order? HELP?

Any suggestions?

Rocky.... :D

OK it took some time, but I did find a simple solution. If you add a field called Count to the table and the form and set it to the number of copies of each label. (the text box on the form can be invisble, but must be there.) Then in the section detail print event add the following code.

Sub Detail_Print(Cancle As Integer, PrintCount As Integer)
If Me!txtLabelCount = 0 Then
Me.NextRecord = True
Me.MoveLayout = False
Me.PrintSection = False
Else
If PrintCount < Me!txtLabelCount Then
Me.NextRecord = False
End If
End If
End Sub

This comes from an old Sybex book by Ken Getz, Paul Litwin & Greg Reddick titled "Microsoft Access 2 Developer's Handbook" ISBN: 0-7821-1327-3 good stuff still today! :)
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
This help?

Code:
Option Compare Database 
Option Explicit 

'This Code was provided courtesy of tek-tips.com, thread703-431337 

'Dim intItemsPerPage As Integer ' # items to print per page 
'Dim txtCopiesWanted As TextBox ' TextBox containing # copies to print 

Dim intCopiesWanted As Integer ' # copies of current record to be printed 
Dim intCopiesPrinted As Integer ' # copies already printed for current record 
'Dim intItemPos As Integer ' Next position to be printed 
' Position 1 is top left, position 2 is either the next column to the 
' right or the first column in the next row, depending on whether you 
' are printing across then down, or down then across (page setup) 

Private Sub Report_Open(Cancel As Integer) 
' Initialize intItemsPerPage to the number of cards on a page 
' intItemsPerPage = 4 
' Set txtCopiesWanted to the TextBox control giving the copy count 
' for each record 
' Set txtCopiesWanted = [txtNumOfVehicles] 
End Sub 

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) 
' Get # copies of this record to be printed 
'intCopiesWanted = Nz(Val(txtNumOfVehicles)) 
intCopiesWanted = Me.txtNumOfVehicles.Value 
' If # copies to print <= 0, don't print anything and skip this record 
If intCopiesWanted <= 0 Then 
MoveLayout = False 
PrintSection = False 
NextRecord = True 
Exit Sub 
End If 

' If this is the first time formatting this record, reset the copy counter 
If Me.FormatCount = 1 Then intCopiesPrinted = 0 

'' Track the position where this item will be printed 
' intItemPos = intItemPos + 1 

'' Access always tries to add too much data to a page. When it finds out 
' the page is full, it prints it and formats the same record again for 
' the next page, so if our page is full, ignore this call; we'll decide 
' what to do when it's formatted for the next page. 
' If intItemPos > intItemsPerPage Then Exit Sub 

' Don't print this item if we have already printed enough 
If intCopiesPrinted >= intCopiesWanted Then Me.PrintSection = False 

' Don't move to the next record if we haven't printed enough 
' copies yet, or if there are more items to skip on the page 
If intCopiesPrinted + 1 < intCopiesWanted Then ' _ 
' Or intItemPos < intItemsPerPage Then 
NextRecord = False 
End If 
End Sub 

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer) 
' Keep count of how many copies of this item have been printed 
intCopiesPrinted = intCopiesPrinted + 1 
End Sub 

Private Sub Report_Page() 
' When a page has been printed, reset the item position to top left 
' intItemPos = 0 
End Sub

I haven't used this code but I have been told it works. Let me know if you have any additional questions...

HTH,
 
Upvote 0
Re: Solved ** Print multiple up labels with variable label c

When I tried the solution sugested by Corticus all the refferences to Timer (I'm using a script to automate alot of keyboard entry so need the system to "wait" for several processes to complete\system response) stopped working. Then I couldn't delete the code. Thankfully I had taken a backup copy of my application.
Perhaps it's my lack of experience or could be something nasty in the woodpile?
 
Upvote 0

Forum statistics

Threads
1,221,704
Messages
6,161,390
Members
451,701
Latest member
ckrings

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top