Gasman
Enthusiastic Amateur
- Local time
- Today, 09:24
- Joined
- Sep 21, 2011
- Messages
- 17,515
Would this be of any use?
Indeed it would. It includes the comparatively easy part of fetching print job info from the print queue. I added something similar as a fallback because the print spooler events API function behave somewhat unpredictably in regards to the data the can be retrieved with their events.Would this be of any use?
The tangible information is in the print queue (print spooler). Luckily it's not really the printer itself that needs to be interrogated for that information. It is in the windows print spooler already. This is very fortunate, because there is no need for "advanced printers". Basically every printer that has a Windows driver should be good enough. However, some printer drivers (e.g., "Microsoft Print to PDF") don't support the notifications from the spooler.This is always going to come back to this question: "What - and where - is the measurable property?" If you cannot get feedback from the printer such as notification for advanced printers, there is no way to answer this question.
Sorry. That was a foreign language issue. I only noticed now that "is printed" is likely being read as "completed printing" while a literal translation to my language would be "is in the process of being printed".Your question and desire contradict each other.
In theory you are right. The problem is that I need to know *when* to get the status from the print queue. Too frequent polling would waste resources and block the Access UI, while too infrequent polling might miss the report being in the queue.Anyway, send print jobs to the spooler. Your Access app can call WinAPI's to get a status from the printer server as to whether the job is queued for printing, currently printing, or cancelled.
I only noticed now that "is printed" is likely being read as "completed printing" while a literal translation to my language would be "is in the process of being printed".
The answer to the modified question is, start asking immediately after you open the report object. Check for it in the appropriate print queue on a one-second timer loop until you see the job or you reach a time-out point when the report object has been closed for at least 10-15 seconds. Your comments about using CTRL/P to trigger printing from the Preview screen means you might not have a clear-cut event for when it gets sent out for printing. Therefore, you have to have that loop running during the time it COULD be requested by command or keyboard shortcut.The problem is that I need to know *when* to get the status from the print queue.
The data in the report is some sort of contract. As long as it wasn't printed, it is allowed that users or the application automatically make changes to the data. Once it is printed, changes are no longer allowed. I need to know when it is printed to mark the data as "printed".Are you keeping track of usage stats? Do you actually CARE about someone opening a report in Print Preview and then closing it without printing?
That scenario is unlikely to happen. Nonetheless, creating a PDF from the report also qualifies as "printing" in the context of the process, regardless of whether the PDF is eventually printed on paper or not.What happens if a user prints your report to a PDF then sends the PDF to the printer? Is that out of scope of what you are trying to catch?
Yikes!So why not just track the contract's print status within the Access app
Of course, Adobe Sign or Docusign could be integrated in a comprehensive manner.In the real world, a contract is not legally binding until it has been signed by all parties and returned to the party that created the contract. Perhaps you should obtain proof the contract has been signed by all parties and then updating the status? Just because a contract has been printed does not mean the contract cannot be amended or cancelled.
I reply to this because that's the potential(!) flaw with your code suggested in #34.Use a timer to poll the status every 500 ticks (half second).You can set a limit of 10 seconds, (20 polls) using a loop. Play with the polling frequency and total time until you feel it's right.
That's true of course. But printing the report creates a Schrödinger's contract from the application's point of view. It is a disconnected copy of the data that might be signed or might be shredded. The safe bet is to assume it is signed. If the contract needs to be cancelled of amended than users can do that in the application.In the real world, a contract is not legally binding until it has been signed by all parties and returned to the party that created the contract.
This is a million times more likely to be forgotten by users than their instruction to not print from print preview, which already gets forgotten often enough for this task to have ended up on my todo list.Perhaps you should obtain proof the contract has been signed by all parties and then updating the status?
In theory it could.An online service that provides a work flow for distributing documents, signing, and return could be integrated via API's to automate the status update in your Access app.
I don't like this idea for reasons I will explain in the post after the next (#51).one new idea is to not have a Preview button.
I do not care whether the customer received their copy.then I think you're over complicating the need to know if they received the paper copy, when your app can just change the status of the contract to 'printed' so your users cannot edit the contract.
Well, the requirement to not print from preview was the status quo ante. The objective of this thread's underlying question was to get rid of this requirement.One of your issues with the PDF is that it is different from other reports, but this one is already different because you a requiring the user to remember never to print from preview.
That was a problem with the polling of the printer queue suggested by others. Polling the queue is indeed problematic and for exactly this reason I rejected those suggestions. - My solution (outlined before and below) does not suffer from this problem.and how quickly your queue sampling code got to it.
This was that type of unverified AI output I asked not to post.Try the code below that uses Windows Management Instrumentation through the GetObject function to detect the status of remote print jobs.
The code you posted takes on average 850 ticks to run when querying the queue of a local printer already. I couldn't test it, but I'm convinced it will take longer for a remote print queue.Use a timer to poll the status every 500 ticks (half second).You can set a limit of 10 seconds, (20 polls) using a loop. Play with the polling frequency and total time until you feel it's right.
I find it hard already to justify to educate users to not use an innocent keyboard shortcut like [CTRL]+[P]. - I personally hate it, when applications do not support generic standard shortcuts of the OS.I'm with RonPaii on the idea that this is ALSO an employee education problem.
I do not know and I do not care.How often have customers not received a copy?
The user never pressed the print button.Just set contract's print status as printed immediately after users press the print button and be done with it