How to show / print a system variable in a report

C

Charles

I am using the rather technique shown in:

The Knowledge Base Article ID : 95806
How to Skip Used Mailing Labels and Print Duplicates

Which works a treat.

What I would like to do, on each "label", is to have a control that shows
something like:

Label No X of XX

The normal "Runing Sum" method seems not to respond in the way I want.

There are a number of variables in the code, which is reproduced below:

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

'==================================================

It seems to me that somewhere / somehow, I should be able to use " CopyCount
".
 
A

Allen Browne

The technique described in that article is flawed.

It relies on repeating some report events, but if you print just some pages
of the report (e.g. starting at page 5), the events for the intervening
pages may not fire, and so you get incorrect results.

For a more reliable approach, see:
Printing a Quantity of a Label
at:
http://allenbrowne.com/ser-39.html
The article explains how to generate the right number of records for the
labels (using a Cartesian Product query), and also explains how to add the
"Label x of y" to each label.
 
C

Charles

Wow, What a speedy response. Thank you very much. It gives me a better
approach.

The question is no longer relevant to my immediate problem but . . . .

Is there a way of printing the variable on the report?
 
A

Allen Browne

What variable?

You cannot use a VBA variable directly in the Control Source of a text box.

You can use a report event to assign the value of the variable to an unbound
text box. Or you can write a VBA function that returns the value of the
variable, and set the Control Source of the text box to the name of the
function, e.g.:
=GetMyVar()
 
G

Guest

In A97 you could declare a public property of the report,
and use it as a data source:

Option Compare Database
Option Explicit
Public CopyCount&

and

=[report].[copycount]

but I don't think that works in A2003, so it should be avoided.

(david)
 
C

Charles

The direct answer to the question is : CopyCount& (see below).

Notwithstanding your comments about the code being "flawed", trying to work
out how to follow this latest advice will keep me amused for a number of
minutes.

(I am quite an amateur and very much into "discovery learning" ! )

Once again,
Many thanks
Charles
 
C

Charles

I tried to say thank you some days ago, but for some reason, I could not get
the "reply" feature to work.

I have yet to try what you have suggested but when I do, I will get back to
you. It certainly looks to be simple enough for me.


--
Thank You


david@epsomdotcomdotau said:
In A97 you could declare a public property of the report,
and use it as a data source:

Option Compare Database
Option Explicit
Public CopyCount&

and

=[report].[copycount]

but I don't think that works in A2003, so it should be avoided.

(david)


Charles said:
I am using the rather technique shown in:

The Knowledge Base Article ID : 95806
How to Skip Used Mailing Labels and Print Duplicates

Which works a treat.

What I would like to do, on each "label", is to have a control that shows
something like:

Label No X of XX

The normal "Runing Sum" method seems not to respond in the way I want.

There are a number of variables in the code, which is reproduced below:

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

'==================================================

It seems to me that somewhere / somehow, I should be able to use " CopyCount
".
 

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