Mailing List code bug for FredG

J

Jeff Conrad

Hi,

This message is mostly for Fred, but anyone else is most welcome to join in.

I've been using some code supplied by Fred to print multiple copies of
address labels and to start at a specific position on the first page. I've
been using it for a long time with no problems, in fact I've even passed on
the code to other NG posters. Recently, however, I stumbled across something
VERY weird about this only because I never tried it before!

The code will prompt the user for the starting position as well as how many
copies of each label to print. I took this a step further and make a real
slick form to gather this information instead of having the prompts. The
form has a graphical display of 30 labels on the sheet and you just click
which one you want to start on. Then the user enters how many copies of each
with the default set at one. I thought this form was the cause of the
"weirdness" (explained in a minute), but it's not. Just using the following
steps make it happen every time.

Here are the steps to reproduce:

1. Setup just as Fred describes:This will permit you to enter the number of times to
repeat the labels, as well as skip missing label positions
on an already used sheet.

First make sure your label report properly prints 1 label
per record.

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 SkipCounter
2) Leave the second control unbound.
Name this control SkipControl
3) Set the third control's Control Source to:
=[Repeat how many]
Name it RepeatCounter

Next code the Report Header OnFormat event:

Private Sub ReportHeader_Format(Cancel As Integer,
FormatCount As
Integer)
[SkipControl] = "Skip"
Cancel = True
End Sub
=======
Now code the Detail OnPrint 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
If IsNull([RepeatCounter]) Then
ElseIf intMyPrint Mod [RepeatCounter] = 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 labels to
skip, then how many times to repeat each label.
FredG
2. OK, in my test data I have 16 vendors, but I don't think it matters how
many. I have 30 labels on a sheet, but again I don't think this is
significant either. For the sake of testing please try and match these
requirements.

3. Open the report from the database window and select any number for
starting position and only 1 repeat. Should be one page no problems. Close
the report.

4. The MAGIC number for me is ANYTHING after 3 pages in length for the
report. So, for example, if I say 0 starting and 4 repeats then the
"weirdness" happens!!! OK, Jeff what "weirdness"!!

You must do this EXACTLY like I say!!
First Test:
- Open the report and select 0 and then 4
- At the bottom left corner are the page selectors
- BEFORE DOING ANYTHING ELSE click the far right one that should take you to
the last page
- You should see a slight screen flicker, but the page does NOT change.
You're still on page 1!
- Think that's weird? Now try clicking the button that will advance the page
one at a time. The number will change to 2 and the new labels will also
appear. Fine. Now keep GOING one page at a time and see what happens!!!! The
labels displayed do NOT change AND the number will just keep going and going
and going to infinity!!! Even if I change the view to show six pages at a
time it will show six pages of the same thing over and over and over even
though I know it is only a three page report!!! Weird! If I hit the last
page button it just goes bonkers.

Second Test:
- Open the report and select 0 and then 4 again
- Advance the report by one page at a time WITHOUT hitting the last page
button. The numbers correctly stop at 3 and the labels displayed are fine.
So what's the problem with the last page button and this code?

5. I was VERY afraid to actually hit the print button for fear of an endless
stream of pages coming out! But, to complete the test I bit the bullet and
hit print. It correctly printed only 3 pages even though my screen said 99
pages at that moment! Whew!

6. One last note before everyone goes "I'm not seeing this." This
"weirdness" only happens on Access 97 and 2000. I do NOT see this behavior
on Access 2002 or 2003. I have done a LOT of testing on various operating
systems and page numbers, but it only occurs on 97 and 2000. For the last
two versions no matter how big the report was (and I tried really big)
clicking the last page button correctly took me to the last page after a few
seconds. And yes, I believe each system had the latest service packs and Jet
updates.

So my questions:
1. Can anyone else see this on 97 or 2000?
2. Why does this problem happen on 97 and 2000?
3. Anyway around this? The users want to know how many pages are going to
print, but they're afraid to hit the print button!

Thanks for any comments and/or thoughts.
Jeff Conrad
Bend, Oregon
 
F

fredg

Hi,

This message is mostly for Fred, but anyone else is most welcome to join in.
*** snipped ***
Here are the steps to reproduce:
*** snipped ***

2. OK, in my test data I have 16 vendors, but I don't think it matters how
many. I have 30 labels on a sheet, but again I don't think this is
significant either. For the sake of testing please try and match these
requirements.

3. Open the report from the database window and select any number for
starting position and only 1 repeat. Should be one page no problems. Close
the report.

4. The MAGIC number for me is ANYTHING after 3 pages in length for the
report. So, for example, if I say 0 starting and 4 repeats then the
"weirdness" happens!!! OK, Jeff what "weirdness"!!

You must do this EXACTLY like I say!!
First Test:
- Open the report and select 0 and then 4
- At the bottom left corner are the page selectors
- BEFORE DOING ANYTHING ELSE click the far right one that should take you to
the last page
- You should see a slight screen flicker, but the page does NOT change.
You're still on page 1!
- Think that's weird? Now try clicking the button that will advance the page
one at a time. The number will change to 2 and the new labels will also
appear. Fine. Now keep GOING one page at a time and see what happens!!!! The
labels displayed do NOT change AND the number will just keep going and going
and going to infinity!!! Even if I change the view to show six pages at a
time it will show six pages of the same thing over and over and over even
though I know it is only a three page report!!! Weird! If I hit the last
page button it just goes bonkers.

Second Test:
- Open the report and select 0 and then 4 again
- Advance the report by one page at a time WITHOUT hitting the last page
button. The numbers correctly stop at 3 and the labels displayed are fine.
So what's the problem with the last page button and this code?

5. I was VERY afraid to actually hit the print button for fear of an endless
stream of pages coming out! But, to complete the test I bit the bullet and
hit print. It correctly printed only 3 pages even though my screen said 99
pages at that moment! Whew!

6. One last note before everyone goes "I'm not seeing this." This
"weirdness" only happens on Access 97 and 2000. I do NOT see this behavior
on Access 2002 or 2003. I have done a LOT of testing on various operating
systems and page numbers, but it only occurs on 97 and 2000. For the last
two versions no matter how big the report was (and I tried really big)
clicking the last page button correctly took me to the last page after a few
seconds. And yes, I believe each system had the latest service packs and Jet
updates.

So my questions:
1. Can anyone else see this on 97 or 2000?
2. Why does this problem happen on 97 and 2000?
3. Anyway around this? The users want to know how many pages are going to
print, but they're afraid to hit the print button!

Thanks for any comments and/or thoughts.
Jeff Conrad
Bend, Oregon

Jeff,

1) I don't have the form with the layout you are using, so of course I
can't comment on that. I use a couple of controls on a form and simply
enter the number of labels to skip and/or repeat.

2) The code you are using uses nextrecord, printsection and movelayout
in the Print Event to advance (or not advance) as needed. If you don't
actually print (or preview) the pages, one at a time in order, the
events do not fire and Access 'gets lost'. When you went to the last
page first that's what happened.
It's a non-issue for me, as the idea of generating labels is to print
them, otherwise filter out the ones you don't want in the report's
record source. As you said this has worked properly all along ....
(until you got to experimenting) <g>.
In the Marx brothers movie "Coconuts" (I think, or maybe "A Day at the
Races") when Margaret Dumont complains "Dr. Quackenbush, when I go
like this 'cough', 'cough', it hurts", Groucho Marks replies 'Don't go
like this."

If this remains an issue, I would suggest you use an alternative
method to print multiple labels, using a table with as many records as
you might eventually want to print.
Allen Browne has information at his web site
http://members.iinet.net.au/~allenbrowne/ser-39.html
 
J

Jeff Conrad

Hi ya Fred!
1) I don't have the form with the layout you are using, so of course I
can't comment on that. I use a couple of controls on a form and simply
enter the number of labels to skip and/or repeat.

I thought maybe my form was interfering some how, but it's not the form
trust me. All of these tests mentioned above were created in a new blank
database with one table and a simple label report. The only code in the
report is your code and the controls you suggest. So I wanted to get a
"true" test that someone else could reproduce.
2) The code you are using uses nextrecord, printsection and movelayout
in the Print Event to advance (or not advance) as needed. If you don't
actually print (or preview) the pages, one at a time in order, the
events do not fire and Access 'gets lost'. When you went to the last
page first that's what happened.

Am I to guess you were able to reproduce this in 97 or 2000? Wasn't quite
clear from your response. Yes, I would agree Access is "getting lost"
somewhere. "HAL, stopping printing the pages......HAL??....."

But, why does this problem NOT occur in 2002 and 2003??
That's the $60,000 question!
It's a non-issue for me, as the idea of generating labels is to print
them, otherwise filter out the ones you don't want in the report's
record source. As you said this has worked properly all along ....
(until you got to experimenting) <g>.

Yes, for better or for worse I extensively test things and occasionally come
across the bizarre. But, I want to test for every weird thing a user might
do. Just happened to stumble on this.
In the Marx brothers movie "Coconuts" (I think, or maybe "A Day at the
Races") when Margaret Dumont complains "Dr. Quackenbush, when I go
like this 'cough', 'cough', it hurts", Groucho Marks replies 'Don't go
like this."

LOL!!
I guess some training is involved here:
"Don't press that button!"
If this remains an issue, I would suggest you use an alternative
method to print multiple labels, using a table with as many records as
you might eventually want to print.
Allen Browne has information at his web site
http://members.iinet.net.au/~allenbrowne/ser-39.html

I wouldn't say it's an "issue" since hitting the print button does print the
correct number of pages on the printer. If it never stopped printing then it
WOULD be an issue! I really like my form interface as it gives the user a
visual reference with which to start the printing using 30 labels that look
like command buttons so I think I'll just stick with what I have. However, I
will certainly check out Allen's article to see his alternative. Always
eager to learn something new in Access!

Thanks for the help Fred,
Jeff Conrad
Bend, Oregon
 

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