- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
How does a pop-up prevent the print queue from letting jobs skip ahead? I mean if there are 100 jobs in the queue before the pop up appears, what's to prevent number 100 from printing before number 50? Or were more details omitted?
Admin
Can it really be called a print "queue" when items can suddenly appear anywhere but at the end?
edit: snoofle, my interpretation is that there's a bug in the print queue system that places jobs at of order when the queue gets too full (> 100 jobs).
Admin
could he not have used a sleep() statement instead of a dialog box?
Admin
That's more of a print heap or like a print array, not a queue.
If the printer's queue is full, it should just start blocking print calls.
Admin
I thought the same thing at first, but this is the real world where printers run out of toner and paper on a regular basis. The dialog box allows the end user to make sure everything is printing fine before continuing.
Admin
Aside: Seems to me the developer myopically looked at his own code - saw no bugs - and declared the problem non-existent, and refused to delve deeper until forced to by (what in this case is sensible) management. The print queue is a wtf but this (developer) seems a bigger wtf!
Admin
This comment is first. It cut ahead in the queue.
my god, sendkeys? what kind of halfwit uses that hack on a multitasking system?
Admin
So the WTF is that John is a hack with no development skills, who is incapable of solving the problem?
Admin
in before "The real WTF is Microsoft Access."
Admin
He could use a sleep call. Win32 also appears to provide some APIs that can tell you whether the printer is ready to print, which could be used to decide whether to wait or not.
Admin
Admin
TRWTF is indeed the developer. Just because it works with sample/test data doesn't mean it won't break on a real system. Sounds a bit up himself tbh.
Admin
I will agree, he didn't do a good job testing. Sure, your code seems to be fine, but your code doesn't execute in a vacuum. Nor does it execute on 30 pieces of data. I've seen many times that a solution works fine for the first x many, then goes wonky after that. For example, I've seen a list that said its maximum was 255 items stop working correctly after 127. Gee, I wonder what the problem was.
Admin
So there was a bug in the print server? Were they maybe not using a windows server for the print queue and each pc was sending out jobs to the printer itself (basically each PC would have it's own print queue?)
Admin
But it Works on My Machine™
Admin
Should have built a basic machine to be the printer queue instead of using the printer's clearly buggy internal software.
Or alternatively had your application print to a central application that actually does the printing, although that is too much work.
Admin
We have a similar WTF in our billing system. If we generate PDFs for lots of invoices in parallel some of them will become corrupted and display wrong text or some text might disappear altogether. If we set it to produce only one PDF at a time, then no more errors. We suspect the PDF generator might be using IE in the background and that that isn't thread-safe. Doing it one-by-one is obviously much slower than using all of the server's eight cores.
Admin
Replacing a WTF with WTF solution. WTF?!
CAPTCHA: quis - how appropriate.
Admin
It would seem that the application is sending the invoices as one print job per invoice. The entire set of invoices should be sent as one print job.
Print queues are supposed to function as queues - first in, first out. However, this is always subject to job priorities and operator manipulation (and the ham-handedness of newbie OS and hardware developers) -- an application developer should never depend upon an external print queue to always print his jobs in order - Things Happen.
I have seen printouts appear in all kinds of wacky orders, and we haven't even touched on having multiple print devices per queue (which any good admin should know how -- and when -- to use)... But /within/ a print job, one should always expect the output to be in order.
Admin
Kind of like Diebold's voting system central tabulator. It works fine when only a few precincts are dialing their results in, but when there are lots of precincts in a county it tends to drop some results:
http://voices.washingtonpost.com/the-trail/2008/08/21/ohio_voting_machines_contained.html
Of course, it's just a coincidence that highly populated counties are heavily Democratic, right? Maybe, maybe not:
http://query.nytimes.com/gst/fullpage.html?res=9804E3DC1339F93AA35752C1A9659C8B63
If you want to know more about this stuff you can email me at Gmail.
Admin
I believe turning off 'Print spooled documents first' in the advanced printer properties would have prevented the documents from being printer out of order. Then again, who am I to judge? ;)
Admin
Oh yeah, been there, done that.
The worst was the dreaded Excel hack for printing to file. The API was missing a parameter to specify the file name. Instead it would pop up a prompt to fill it out. Obviously an impediment to automation.
You had to assume the application had focus, then send the keys, but not too fast, in case the machine was bogging down near the end of its run. Something like 2 seconds pause per key. However, the long pauses left the application vulnerable to losing keyboard focus during that time.
So of course, no one could touch the machine while it was doing whatever huge report run with the application. Should keyboard focus be lost at any time, you'd end up with one or more missing reports, a mess to sort out the next day, and still have to set up for next run.
The mouse could be unplugged, but we had to keep the keyboard plugged in, something about it not working when plugged in again. So we devised a set of nesting boxes like Marushka dolls for the keyboard, each box with increasingly dire warnings to keep away.
After stacking the boxes, you'd pause a bit and watch the screen, like checking a baby if it's okay, take a deep breath, then turn off the light and go home.
Admin
The real WTF is indeed the developer.
What's so wrong about taking the printer offline, letting all print jobs queue, and then taking the printer back online? I suppose the printer is dedicated for the invoice processing anyways. It would have the added benefit that users can decice when they want the printout to begin.
Admin
I have to agree with several others on here that the "not my problem/fault" attitude of the developer was less than helpful.
Admin
You know you could write a SendKeys macro to dismiss that MessageBox right? :-)
Admin
IIRC, sleep() was the first thing I tried. The question is...how long do you sleep? Is a minute long enough? Five minutes? Thirty minutes?
What I needed was some way to tell when the printer had finished spitting out invoices. There is no Windows API for that.
So, I put the message box in place, and instructed the accounting clerks to hit "OK" as soon as the printer stopped printing.
I agree that this is a suboptimal fix. Can you suggest an optimal fix, one implemented entirely in VBA code?
As for testing...any of us would like to think that our testing of this process would, of course, naturally include going through each of the hundreds of invoices by hand, one by one, to make sure they are all in order.
I mean, we are ALL that thorough in our testing, aren't we? And we would follow it through all the way to the end, JUST IN CASE the first 120 were fine, but the next fifteen were not? Even when we have no reason to believe the invoices will print out of order, since they had never done this before?
SURE we would.
Admin
Admin
I don't remember exactly what I tried (this was years ago), but I distinctly remember trying all the different combinations of settings for that stupid printer. It made no difference.
Admin
What is the difference between a light bulb going off and a light bulb turning on?
Admin
Admin
HAHAHA. I found a typo in the article! Two transposed letters. Pedantic grammar and spelling luser wins!
Admin
No where here have I seen the ABSOLUTE EASIEST METHOD of fixing this
... its called "PRINT DIRECT",
which eliminates the queue altogether. Therefore bypassing this problem altogether. Sure you would have had an error when you ran out of paper or something, but you could have trapped that right off in the code.
Admin
Admin
Why isn't he sending all of the data for one customer as one print job ?
Admin
Admin
Admin
What kind of nitwit uses Access and VB in the first place? I mean, if you're going to start peeling the nitwit onion, you'll have to peel it all the way down to Redmond...
Admin
But a flash bulb going off is exactly the same as a light bulb turning on, if that helps.
Admin
Admin
5 minutes of googling: http://www.visualbasic.happycodings.com/Applications-VBA/code9.html
Although the real answer is generating the invoices in such a way that they are one continuous print job.
Admin
used hack^H^H^H^H send keys multiple times, I have.
Admin
Get out of your ivory tower and actually talk to some end users. You'll learn very quickly to make things as simple, idiot-proof and seeded with big, brightly colored candy-like buttons as possible so that there's even a glimmer of hope that they'll get it right.
Admin
This would tell me the state of the local print queue, correct? The local print queue was behaving normally. It was some sort of abstraction layer between the operating system and the printer that was causing the problem.
True, I never saw this mythical abstraction layer with my own eyes, but how else do you explain:
Admin
As i hadn't read the manual, i'd enter... 0? I want printing to be FAST!
Admin
Was AppActivate not available in VBA like it was in VBScript? Assuming so, an AppActivate before every keystroke, combined with only sending one keystroke at a time would have solved that problem. I could be remembering VBAs features incorrectly though.
It wasn't a pretty way to automate things, but it sort of worked (atleast in VBScript).
Admin
Incidentally, it gets worse. There are USB devices out there that automatically install software on connection by pretending to be a HID (keyboard) and sending a lot of keystrokes. Some do this in conjunction with also pretending to be a USB floppy, and sending the keystrokes '-startmenu-R-enter-A:\SETUP.EXE-enter-'. One that a colleague of mine once saw even fired up cmd.exe and ran debug.com to enter a small program, hex byte by hex byte!
Hammer a few random keys in the middle of that and you've changed a BIOS 'int' call into something else... potentially trashing your MBR or something important like that. Brillant!
Admin
there's a truth here. Management will always choose the sub-optimal solution.
Admin
Admin
There should have been one print job sent to the printer containing all the invoices sorted in proper sequence for stuffing in envelopes. That's exceedingly easy to do.
"agonizingly slow JET database engine" is wrong. Jet's performance is quite good and in simple situations can outperform SQL Server. Yes, SQL Server is a better solution for complex applications or mission critical systems.
I have apps with tables with over a million records working just fine.
Tony Toews, Microsoft Access MVP
Admin
[quote] Although the real answer is generating the invoices in such a way that they are one continuous print job.[/quote] As for sending them all in one print job...is there a way to print Access reports that way? [/quote]
Exceedingly easy. I'm quite puzzled as to why they didn't do that.
Tony Toews, Microsoft Access MVP