Jim Dettman
jimdettman at verizon.net
Wed May 5 14:00:49 CDT 2010
Rocky, The wait() function I posted has the advantage that you still have control in VBA while waiting, so it's possible to put up a message (i.e. "You have xx more seconds to wait"). When you use Sleep, your done for 30 seconds no matter what. Depends on what you need. If it's just wait, then Dan's would be the most efficient and accurate. Jim. -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin Sent: Wednesday, May 05, 2010 2:16 PM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Timer Routine needed - or some other solution? I already forwarded Dan's solution - I'll send this along as well. The thing that worries me about that is how much of the CPU will be consumed in the loop. But I'll suggest it and see if it works. Also, I'm not sure that there's something else going on that's hosing the order in the print queue. But we'll see. Thanks Rocky -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jim Dettman Sent: Wednesday, May 05, 2010 10:42 AM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Timer Routine needed - or some other solution? Rocky, You can use the function below, but I generally find anything that is time based is always problematic. Jim. Public Function Wait(intSeconds As Integer) As Integer Dim datCurDateTime As Date 10 datCurDateTime = Now 20 Do Until DateDiff("s", datCurDateTime, Now) > intSeconds 30 DoEvents 40 Loop End Function -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin Sent: Wednesday, May 05, 2010 12:16 PM To: 'Access Developers discussion and problem solving' Subject: [AccessD] Timer Routine needed - or some other solution? Dear List: The problem is that mdb 1 calls a module in mdb 2 which prints 4-5 reports - to a network printer. The user wants those reports to come out in a specific order, so the module calls them in that specific order. But when the reports print, they come out in a different order - random or scrambled according to the user. So user asks me to write some kind of timer routine that would delay the call to the next report by 30 seconds. Now the calls are in a module so I can't use the timer event. A nice tight loop checking the computer's clock would work except it might suck up so many machine cycles the reports might not get printed. In any event, not much else would go on in that machine while it was running the loop. I asked him to take the printer off line and look at the queue to see what order the reports are in there, but can't get him to do that. Asked him to hook up a local printer and see how the reports come out and, if scrambled, take it off line and see what the queue looks like. But he's really insistent that the first thing we try is to program our way into an orderly report printing. I did get him to concede that he could put the report printing code in a module behind a form in which I could embed a timer event. So, what to do? I'm looking at a minimum for a way to separate the printing of the reports in the module (he tried DoEvents but that didn't help) by 30 seconds or so. If by some miracle that works, then problem solved. If it fails then maybe I can get him to look at another approach. MTIA Rocky -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com