Compile error when implementing "How to skip Used Mailing Labels"

G

Guest

I get compile errors when trying to implement the "How to skip Used Mailing
Labels"
Article ID: 95806
On Print Property of label "MYLabels"
=LabelLayout(Reports![MyLabels])
Error is Expecting line number,or label or statement.
also
OnOpen property
=LabelSetup()
On Format property of Header
=LabelInitialize()
 
B

Brendan Reynolds

Probably, when you copied and pasted the code, you missed the first comment
character, i.e. the first line in your module begins with a * instead of a '
 
G

Guest

Still get errors.
My Module looks like:

'*********************************************************
'Declarations section of the module.
'*********************************************************
Option Compare Database
Option Explicit

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

'==========================================================
' 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

My report Looks like:

Option Compare Database

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
=LabelLayout (Reports![MyLabels])

End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
=LabelInitialize()
End Sub
Private Sub Report_Open(Cancel As Integer)
=LabelInitialize
End Sub



Brendan Reynolds said:
Probably, when you copied and pasted the code, you missed the first comment
character, i.e. the first line in your module begins with a * instead of a '

--
Brendan Reynolds
Access MVP

Bob B said:
I get compile errors when trying to implement the "How to skip Used Mailing
Labels"
Article ID: 95806
On Print Property of label "MYLabels"
=LabelLayout(Reports![MyLabels])
Error is Expecting line number,or label or statement.
also
OnOpen property
=LabelSetup()
On Format property of Header
=LabelInitialize()
 
B

Brendan Reynolds

The expressions (e.g. "=LabelLayout (Reports![MyLabels])",
"=LabelInitialize()") are supposed to go directly in the properties, not
into event procedures. Like so ...

http://brenreyn.brinkster.net/expression.jpg

--
Brendan Reynolds
Access MVP

Bob B said:
Still get errors.
My Module looks like:

'*********************************************************
'Declarations section of the module.
'*********************************************************
Option Compare Database
Option Explicit

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

'==========================================================
' 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

My report Looks like:

Option Compare Database

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
=LabelLayout (Reports![MyLabels])

End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
=LabelInitialize()
End Sub
Private Sub Report_Open(Cancel As Integer)
=LabelInitialize
End Sub



Brendan Reynolds said:
Probably, when you copied and pasted the code, you missed the first
comment
character, i.e. the first line in your module begins with a * instead of
a '

--
Brendan Reynolds
Access MVP

Bob B said:
I get compile errors when trying to implement the "How to skip Used
Mailing
Labels"
Article ID: 95806
On Print Property of label "MYLabels"
=LabelLayout(Reports![MyLabels])
Error is Expecting line number,or label or statement.
also
OnOpen property
=LabelSetup()
On Format property of Header
=LabelInitialize()
 

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