The approach in this function is unreliable.
Despite the fact that it is published in several books and even in one of
Microsoft's knowledgebase article, you will find that you get unreliable
results if you just print (say) page 5 of a label run. The problem is that
the report events may not fire for the intervening pages that were not
printed, so what you end up with is the wrong set of labels and possibly the
wrong count of labels.
There is another solution that relies in generating the records dynamically
in the report's query (using a Cartesian product) instead of relying on the
report's events. Details in:
Printing a Quantity of a Label
at:
http://allenbrowne.com/ser-39.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Ken Mylar" <km****@elch.org> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
I don't recall where I got this function, but it alllows you to skip
labels (if your sheet is missing some already) and also enter how many
you would like.
Create the following Module:
************************************************** ************************
Option Compare Database
Option Explicit
Dim intLabelBlanks As Integer
Dim intLabelCopies As Integer
Dim intBlankCount As Integer
Dim intCopyCount As Integer
'================================================= =========
' The following function will cause an inputbox to
' display when the report is run that prompts the user
' for the number of used labels to skip and how many
' copies of each label should be printed.
'================================================= ==========
Function LabelSetup()
intLabelBlanks = Val(InputBox$("Enter Number of blank labels to
skip"))
intLabelCopies = Val(InputBox$("Enter Number of Copies to
Print"))
If intLabelBlanks < 0 Then intLabelBlanks = 0
If intLabelCopies < 1 Then intLabelCopies = 1
End Function
'================================================= ==========
' The following function sets the variables to a zero
'================================================= ==========
Function LabelInitialize()
intBlankCount = 0
intCopyCount = 0
End Function
'================================================= ==========
' The following function is the main part of this code
' that allows the labels to print as the user desires.
'================================================= ==========
Function LabelLayout(R As Report)
If intBlankCount < intLabelBlanks Then
R.NextRecord = False
R.PrintSection = False
intBlankCount = intBlankCount + 1
Else
If intCopyCount < (intLabelCopies - 1) Then
R.NextRecord = False
intCopyCount = intCopyCount + 1
Else
intCopyCount = 0
End If
End If
End Function
************************************************** *********************************
Then on your label report's OnOpen event put:
=LabelSetup()
Thanks,
Ken