Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Skipping labels and multiple copies of each label in multi-page report

Status
Not open for further replies.

Thingol

Technical User
Jan 2, 2002
169
Hi all,

I found some code from MS on this page that helps skipping used labels in an access report, and printing multiple copies of the labels on one page.

The code works fine as long, as all the copies of the together with the white space do not take up more than one page in the report. When more pages are needed, several thing go wrong:
1) The label sections for the used labels are left white on all pages, instead of just on the first page.
2) The number of copies of the labels is off.

What I need is this:
* Create multiple labels (more than fit on one page) for each record in the query on which the report is based.
* Create white sections on the first page in a print session (the amount which the user enters, which can never be more than the total amount of labels on one page).

Can this be achieved, and if so, how?

Thanks a lot for any help!

Best regards,
Martijn Senden.


In the Beginning there was nothing, which exploded.

--Terry Pratchett, Lords and Ladies--
 
Hi

I am not familiar with the code in question, but I am sure it can be amended to do as you wish

Without seeing the code, I would assume the mechanism to bypass the 'used' labels is code in the on format event of the detail section which suppresses the print until a given number of labels have been processes, extending the if statement to take into account the page number would be the way I would try

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi there,

Thanks. The code is in the microsoft page I linked to, I didn't want to put too much code in the post, but since you asked, here it goes anyway. This is the code I am using, which uses a method similar to your suggestion, but as I've already stated, with multiple pages, things go wrong!

I hope this helps.

Code:
'*********************************************************
'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$("Number of labels to skip:"))
LabelCopies& = Val(InputBox$("Number of copies:"))
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

Best regards,
Martijn Senden.


In the Beginning there was nothing, which exploded.

--Terry Pratchett, Lords and Ladies--
 
Hi

I have not tested this but something like

If BlankCount& < LabelBlanks& Then
If R.page = 1 Then '<---------------
R.NextRecord = False
R.PrintSection = False
BlankCount& = BlankCount& + 1
end if
Else
If CopyCount& < (LabelCopies& - 1) Then
R.NextRecord = False
CopyCount& = CopyCount& + 1
Else
CopyCount& = 0
End If


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi there,

Yes, I had already tried that too. This works for only skipping labels on the first page, but the number of copies is still something that's hard to get right. I noticed that when I use a copycount of more than the total amount of labels on a page, I get an infinite amount of pages!

Is there a way to this without all these bugs (not necessarily using this MS method)?

Best regards,
Martijn Senden.

In the Beginning there was nothing, which exploded.

--Terry Pratchett, Lords and Ladies--
 
Hi all,

I've doen it! The problem with getting multiple copies was in the intialize function:

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

Public Function LabelInitialize()

BlankCount& = 0
If IsNull(CopyCount&) Then
   CopyCount = 0
End If

End Function

I solved the problem with skipping labels on the first page only by using this code instead of the MS code:

Code:
'===========================================================
' The following function is the main part of this code
' that allows the labels to print as the user desires.
'===========================================================

Public Function LabelLayout(R As Report)

BlankCount& = BlankCount& + ((R.Page - 1) * 16)

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

Best regards,
Martijn Senden.

In the Beginning there was nothing, which exploded.

--Terry Pratchett, Lords and Ladies--

In the Beginning there was nothing, which exploded.

--Terry Pratchett, Lords and Ladies--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top