fredg said:
*** snipped ***
I'm new to Access VBA coding. I've followed your steps above, & it still
not skipping the label. Please advice of what I should do to fix this.
Thank you in advance
Sorry, I'm here and you're there, and I can't see your report.
The above code works to skip missing label positions on a label sheet.
I use it all the time.
What does your report do? Does it not skip positions at all? Does it
skip more positions than you entered? Did you add the controls to the
Report Header? Did you name those controls "SkipCounter" and
"SkipControl"? Do you get prompted for the number of labels to skip
when you run the report? Does the report work properly otherwise?
I would suggest you copy and paste into a reply message "your exact"
code, including the Private Sub ... etc.. lines.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Sorry Fred,
First, I like to thank you for you quick respond. That's really nice of you.
Anyway, I tried both copying your codes over & I've tried to type in by
myself. What it is doing is when I run the report, it'll ask for skip how
many. I typed in 1 & the report just print at the 0 position. Here is the
code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount <= [skipCounter] And [skipControl] = "Skip" Then
Me.NextRecord = False
Me.PrintSection = False
Else
[skipControl] = "No"
Me.PrintSection = True
Me.NextRecord = True
End If
End Sub
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
[skipControl] = "Skip"
Cancel = True
End Sub
I just copied and pasted this code, exactly as you sent it to me, into
a label report. It works just fine.
I'll have to re-iterate my question to you from the previous post...
Did you add the 2 controls to the REPORT HEADER?
Did you name those controls "SkipCounter" and "SkipControl"?
Did you leave the Control Source of [SkipControl] blank?
Now I'll add..
What happens if you enter 5 to skip instead of 1?
Check Report Header Format and the Detail Print event lines (on the
property sheet). Does that line on the property sheet say
[Event Procedure]? It should. *** After thinking about it, I think
this is the most likely problem.
Did you try setting a breakpoint in the code, stepping through the
code one line at a time, to read the values of
SkipCounter and [SkipControl]
to see what those values are as the report is running?
In any event, the code is fine so it must be something else you have
or have not done.
Hi Fred,
Once again, thanks for you quick respond.
Yes, I did what you have in the sample code. I also tried to put in 5 to
skip instead of 1. I even double check the [Even Procedure] & it shows
[Event Procedure] in the value of these properties.
But 1 thing I don't know how is to set the breakpoint. Maybe you can give
me some advice.
I was thinking if I need to do anything in my report formatting.
Thanks again in advance!
To set a Breakpoint in your code, open the code window (Click View +
Code). Click in the left gray part of the code window alongside the
line of code you wish to break on.
In this case, we'll set 2 breakpoints.
The first would be the Report Header Format line that says
[SkipControl] = "Skip"
and the second one is on the Detail Print line...
If PrintCount <= [skipCounter] And [skipControl] = "Skip" Then
The lines will become highlighted and a large dot placed to the left
of it.
Exit the code window.
Run the report. Enter, for example, 2 as the number of labels to skip.
The report code will stop and highlight the line
[SkipControl] = "Skip".
While that line is highlighted, hover the cursor over [SkipControl].
It should read Null. Press F8. The next line should be highlighted.
Hover the cursor over [SkipControl] again. It should now read "Skip".
Does it? If so, next press F5.
The report formatting will stop now at the point where the Detail
Print event runs. You can then step through the code, line by line,
either by clicking on the "Step Into" tool button, or pressing F8.
Read the values of PrintCount, [SkipCounter] and [SkipControl] by
hovering the cursor over each of them. The first time PrintCount
should read 1, [SkipCounter] should be whatever the number of labels
to skip you entered (2 in this case), and [SkipControl] should read
"Skip".
Press F8.
The next line will be highlighted. Continue pressing F8 and read the
values as they change. The first 2 times through, only the True part
of the If statement will run and Next Record and PrintSection will be
False.
When PrintCount is greater than [SkipCounter], i.e. 3 in this case,
the Else part of the If statement should run, and [SkipControl] should
change to "No", NextRecord and PrintSection should then be true, and
printing should occur. (Note you won't actually 'see' the printing
occurring until you step all through the code, so at this point, click
on the breakpoint dots to remove them. Press F5, to continue, and the
page should appear, labels starting at position 3. If you still have a
problem, let me know what the readings are.
Don't forget to remove the breakpoints when done debugging.