skip blank labels

  • Thread starter Thread starter Shannon
  • Start date Start date
S

Shannon

I found code on the microsoft web site that I was unable
to apply to my database...won't compile correctly...is
there a simple way to skip used labels when printing to
an inkjet printer using sheets of labels? The code I got
from the web site is below. Thanks, Shannon


Create a new module, and place the following lines in the
Declarations
section:'*************************************************
********
'Declarations section of the module.
'*********************************************************
*

Option Compare Database
Option Explicit

Dim LabelBlanks&
Dim LabelCopies&
Dim BlankCount&
Dim CopyCount&

Type the following
functions:'===============================================
===========
' The following function will cause an input box 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 ()
LabelBlanks& = Val(InputBox$("Enter Number of blank
labels to skip"))
LabelCopies& = Val(InputBox$("Enter Number of Copies
to Print"))
If LabelBlanks& < 0 Then LabelBlanks& = 0
If LabelCopies& < 1 Then LabelCopies& = 1
End Function

'=========================================================
==
' The following function sets the variables to a zero
'=========================================================
==

Function LabelInitialize ()
BlankCount& = 0
CopyCount& = 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 BlankCount& < LabelBlanks& Then
R.NextRecord = False
R.PrintSection = False
BlankCount& = BlankCount& + 1
Else
If CopyCount& < (LabelCopies& - 1) Then
R.NextRecord = False
CopyCount& = CopyCount& + 1
Else
CopyCount& = 0
End If
End If
End Function

Open the report named MyLabels in Design view and add the
following line to the OnPrint property of the detail
section: =LabelLayout(Reports![MyLabels])

Add the following line to the OnOpen property of the
MyLabels report: =LabelSetup()

Although typically labels do not have a report header,
add a report header and footer to the report by clicking
Report Header/Footer on the View menu. Then, add the
following line to the OnFormat property of the report
header: =LabelInitialize()

Set the Height property for both the report header and
report footer to 0.
When you print the report, the report calls the LabelSetup
() function, which first asks you to enter the number of
used labels to skip on the first page (BlankCount) and
then asks how many of each label you want printed
(CopyCount).

When the report header is formatted, it calls the
LabelInitialize() function, so when you switch from
preview to print, the BlankCount and CopyCount fields are
set to zero. As each label is formatted, the LabelLayout
() function adjusts the NextRecord and MoveLayout
properties to skip used labels and to print the desired
duplicates.
 
Shannon,
You're welcome to try this one.

First make sure your label report is properly printing a full sheet of
labels.

Then add a Report Header to your label report.
Add 2 text boxes to the Header.
1) Name one SkipControl
Leave it's control source unbound

2) Name the other SkipCounter
Set it control Source to =[Skip How Many?]

Now code the Report Header Format event as below:

Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)
[SkipControl] = "Skip"
Cancel = True
End Sub
==========

Next code the Detail OnPrint event:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount <= [SkipCounter] And [SkipControl] = "Skip" Then
Me.NextRecord = False
Me.PrintSection = False
Else
[SkipControl] = "No"
Me.PrintSection = True
Me.NextRecord = True
End If

End Sub
=====

When you are ready to run the label report, it will ask how many to
skip.
Then it will run the report.
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Shannon said:
I found code on the microsoft web site that I was unable
to apply to my database...won't compile correctly...is
there a simple way to skip used labels when printing to
an inkjet printer using sheets of labels? The code I got
from the web site is below. Thanks, Shannon


Create a new module, and place the following lines in the
Declarations
section:'*************************************************
********
'Declarations section of the module.
'*********************************************************
*

Option Compare Database
Option Explicit

Dim LabelBlanks&
Dim LabelCopies&
Dim BlankCount&
Dim CopyCount&

Type the following
functions:'===============================================
===========
' The following function will cause an input box 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 ()
LabelBlanks& = Val(InputBox$("Enter Number of blank
labels to skip"))
LabelCopies& = Val(InputBox$("Enter Number of Copies
to Print"))
If LabelBlanks& < 0 Then LabelBlanks& = 0
If LabelCopies& < 1 Then LabelCopies& = 1
End Function

'=========================================================
==
' The following function sets the variables to a zero
'=========================================================
==

Function LabelInitialize ()
BlankCount& = 0
CopyCount& = 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 BlankCount& < LabelBlanks& Then
R.NextRecord = False
R.PrintSection = False
BlankCount& = BlankCount& + 1
Else
If CopyCount& < (LabelCopies& - 1) Then
R.NextRecord = False
CopyCount& = CopyCount& + 1
Else
CopyCount& = 0
End If
End If
End Function

Open the report named MyLabels in Design view and add the
following line to the OnPrint property of the detail
section: =LabelLayout(Reports![MyLabels])

Add the following line to the OnOpen property of the
MyLabels report: =LabelSetup()

Although typically labels do not have a report header,
add a report header and footer to the report by clicking
Report Header/Footer on the View menu. Then, add the
following line to the OnFormat property of the report
header: =LabelInitialize()

Set the Height property for both the report header and
report footer to 0.
When you print the report, the report calls the LabelSetup
() function, which first asks you to enter the number of
used labels to skip on the first page (BlankCount) and
then asks how many of each label you want printed
(CopyCount).

When the report header is formatted, it calls the
LabelInitialize() function, so when you switch from
preview to print, the BlankCount and CopyCount fields are
set to zero. As each label is formatted, the LabelLayout
() function adjusts the NextRecord and MoveLayout
properties to skip used labels and to print the desired
duplicates.
 
Back
Top