Printing labels?

R

Randy

I have used the following code to print out labels based on a
suggestion in the archives, but I get an error message. "Can not find
object referred to"

The error refers to [SkipControl]= "Skip"

Can someone help me with this. Here is the code. I have also entered
the three controls in the report header plus have put a SELECT field in
the Record Source. I tested the select field and it just brings up the
selected records in the report when the code is left out so that is not
an issue.

Option Compare Database

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
If intMyPrint Mod [RepeatCounter] = 0 Then
Me.NextRecord = True
intMyPrint = 0
Else
Me.NextRecord = False
End If
End If


End Sub


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

Guest

What are [SkipControl] and [SkipCounter]? Are the variables declared
somewhere else, or controls on the form that called the report, or are they
controls on the report?
The reason for the question is the answer depends on what kind of objects
they are.
 
R

Randy

They are controls on the report. I was given these instructions to go
in the Report Header. The other instructions were for the Details
section.

Then add a Report Header to the label report.
Add 3 unbound text boxes to the header.
1) Set the Control Source to:
= [Skip how many]
Name this control SkipControl


2) Leave the second control unbound.
Name this control SkipCounter


3) Set the third control's Control Source to:
=[Repeat how many]
Name it RepeatCounter
 
G

Guest

Okay, thanks. Without seeing your report code, I worry about visibility of
the controls; however, first try addesssing them as Me.[SkipControl], etc.
If that doesn't work, post back and we will look at visibility.
 
F

fredg

They are controls on the report. I was given these instructions to go
in the Report Header. The other instructions were for the Details
section.

Then add a Report Header to the label report.
Add 3 unbound text boxes to the header.
1) Set the Control Source to:
= [Skip how many]
Name this control SkipControl

2) Leave the second control unbound.
Name this control SkipCounter

3) Set the third control's Control Source to:
=[Repeat how many]
Name it RepeatCounter

The Control name is "SkipControl", however in the code

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

it is miss-spelled as "SkipContol"
Change the control name in the code to match the actual control name
and it will work just fine.
 
R

Randy

Thank you very much..........I went over it 10 times and couldn't see
the forest for the trees.
 
R

Randy

Now when I run the report it says after correction.

"You can not assign a value to this object."
 
F

fredg

Now when I run the report it says after correction.

"You can not assign a value to this object."

Then you must have done something else incorrectly, as I made a brand
new report, added those 3 controls to the report header, set the 2
control sources as indicated, left the [skipcontrol] unbound, copied
the code from your original post, corrected that code error, and it
ran perfectly.
Did your report run correctly (and print one label per record) before
you started to add this code?
I've been using it for years.
 
R

Randy

I made a copy of the report and took out all the code. When I select
the cases to print using a check box it pulls up the correct cases fine
and shows the report in preview mode. I put the Select field in the
Record control.

The full error message I get with the report with the code=

Run-Time error '2147352567 (80020009)

You can't assign a value to this object.

Does any of the code refer to any objects other than the three I have
placed in the Report Header?
 
R

Randy

Fred I figured it out. The SkipControl was not assigned to the unbound
field based on the previous instructions when I changed it it worked.
 

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