On Wed, 13 Jul 2005 16:52:27 +0545, Sumit wrote:
Hi Everyone,
I used the code given in
http://support.microsoft.com/?kbid=207664
for Repeating Report Records a Specified Number of Times (in Labels)
I introduced a new field "RepeatNumber" in my table so that the Report
Record are repeated the number of times mentioned in this field; this works
fine.
For each type of record, I need to show RecordToRepeat and count in the
report.
Example:
If my data in table is-
RecordToRepeat RepeatNumber
----------------- ---------------
AB 2
CD 1
EF 2
Report should show-
AB - 1
AB - 2
CD - 1
EF - 1
EF - 2
I used running sum over group but it does not work and displays the
following-
AB - 1
AB - 1
CD - 1
EF - 1
EF - 1
Any help would be much appreciated.
Thank you in advance.
Sumit
Here is my method to skip missing label positions and to repeat a
label as indicated in a record field named [QTY].
As written it will print
1 of 3
2 of 3
3 of 3
etc.
on each label.
You can change that if you wish.
First make a regular label report that correctly prints one label per
record.
It assumes a Report Record Source with a field [Qty] that contains the
number of times you wish to repeat a label.
Make sure the [Qty] field (or your equivalent field name) is included
in the Detail section.
Set it's Visible property to No.
Add an Unbound text control to the label detail section where you want
to show the label count number.
Name this control LabelCount
Next add a Report Header to the report.
Add 2 unbound text boxes to the Header.
1) Name one SkipControl
Leave it's Control Source unbound
2) Name the other SkipCounter
Set it's Control Source to:
= [Skip How Many?]
Then code the Report Header Format event as follows:
(watch out for word wrap on the longer lines):
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)
[SkipControl] = "Skip"
Cancel = True
End Sub
=================
Next code the Detail Format event:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If [QTY] <= 0 Or IsNull([QTY]) Then
Me.NextRecord = True
Me.PrintSection = False
Me.MoveLayout = False
End If
End Sub
======
Next code the Detail Print event:
(Note that intMyPrint is Static!!)
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Static intMyPrint As Integer
If PrintCount <= [SkipCounter] And [SkipControl] = "Skip" Then
Me.NextRecord = False
Me.PrintSection = False
intMyPrint = 0
Else
[SkipControl] = "No"
Me.PrintSection = True
Me.NextRecord = True
intMyPrint = intMyPrint + 1
' Print 1 of X on the label
LabelCount = intMyPrint & " of " & [QTY]
If [QTY] <= 0 Then
Me.NextRecord = True
Me.PrintSection = False
Me.MoveLayout = False
Exit Sub
End If
If intMyPrint Mod [QTY] = 0 Then
Me.NextRecord = True
intMyPrint = 0
Else
Me.NextRecord = False
End If
End If
End Sub
=========
When you run the report, it will ask how many missing label positions
to skip.
Then it will repeat labels as indicated in each records [Qty] field.
**Remember to change the [Qty] field to whatever you named your
field.**
Always print all of the labels starting from Page 1
Hope this helps.