Editing the Sleep API to lookup cell for length of pause

Shelby1991

New member
Local time
Today, 15:22
Joined
Sep 4, 2013
Messages
6
I am creating an Electronic Medical Records database (well, a fake one, for medical simulation purposes). The way it works, you select a patient from a drop-down on the "Selection" form, and click a command button to bring you to a "Patient information" report. From that report you can view EKG's , Lab results or Imaging reports.

This database is to be used for medical simulation for medical students. So for i have command buttons for each report, and a check box to "order tests".

When a test is ordered , i have the command buttons linked to go to a different report that appears the same except it has a subreport with the "new" test results in it. If this were an actual hospital , results would not be instantaneous, so i have the sleep api in for the "on load" for the reports with the "new" results.

I would like it so I could enter how long of a delay i want for the loading of a particular report in the dataentry form i have. But I am not the best at VBA, and I cannot seem to figure out how to get the sleep api to get the value for the number of seconds i want to wait from my table.

is there a way to do this? weather with the sleep api or not?
 
Last edited:
everytime i attempt to call it using the form control as an argument, i mess up the coding:banghead:, and access closes, and attempts to make another "backup" version of itself... The sleep api (yes, listed there , you actually directed me to that page when i originally questioned how to delay something loading) works fine when I just enter the numbers required, but my boss doesnt want to have to rely on me to change the timings from scenario to scenario, and doesnt know VBA at all.
 
Not sure what to tell you. Just tested and it worked as expected:

sSleep Me.Text12 * 1000
MsgBox "done"

The textbox contained 3, and after clicking the button there was a 3 second pause before the message box.
 
I’ve seen a number of threads relating to the Sleep API unexpectedly failing, and never having seen either an explanation nor a resolution, personally prefer ghudson’s Pause Function.

In a Standard Module

Code:
Public Function Pause(NumberOfSeconds As Variant)
On Error GoTo Err_Pause
    
    Dim PauseTime As Variant, Start As Variant
    
    PauseTime = NumberOfSeconds
    Start = Timer
    Do While Timer < Start + PauseTime
    DoEvents
    Loop
    
Exit_Pause:
    Exit Function
    
Err_Pause:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_Pause
    
End Function
Then, to Call it:

Code:
[B]Pause([I][COLOR="RoyalBlue"]X[/COLOR][/I])[/B]
where X is the number of seconds to pause execution of code.

Linq ;0)>
 
I think there is a lot wrong with this thread...

----------

I do not think it is appropriate to criticize an API call (post #5) without even giving the slightest reason for doing so. All that does is spread fear for no valid reason.

Equally then, there is no reason to post an alternative to the API call especially if that alternative is not well written. The code posted in post #5, and the method of calling it, is far from ideal for many reasons but one glaring problem is the CPU loading incurred.

http://www.fmsinc.com/MicrosoftAccess/modules/examples/AvoidDoEvents.asp

So, take it as you will but remember that the things we read on the web "Ain't Necessarily So"

----------

missinglinq.
Could you please stop bolding so much of your posts on this site? Your contributions and words are important but really no more important than anyone else particularly if you are wrong.

----------

A more serious problem as I see it...

How does one get a job writing medical simulation software for training medical students when both the OP and their boss have no programming skills?

----------

Chris.
 
...I do not think it is appropriate to criticize an API call (post #5) without even giving the slightest reason for doing so...

Sorry, but I certainly did give a reason! I've been disabled for the last years, and have spent 6-8 hours a day, 7 days a week, on this and half a dozen other Access forums, and as I said, have seen a fair number of threads relating to the Sleep API unexpectedly failing, and have never seen either an explanation nor a resolution to the problem.
...there is no reason to post an alternative to the API call especially if that alternative is not well written...

I've used ghudson's hack for quite some time, without any problems, and was only offering a valid alternative to the problem at hand!

Linq
 
Linq.

>>Sorry, but I certainly did give a reason!<
and
>>have never seen either an explanation nor a resolution to the problem.<<

I have trouble with the above, unless you think that people just saying they have had trouble with the API call is sufficient reason not to use it.

The web is full of people who have trouble with API calls, and other things as well, but that does not mean there is something wrong with the API calls. It is more than likely that there is something wrong with the way they are being used.

But, if you have a link to a known problem with the Sleep API then please post it.

Chris.
 

Users who are viewing this thread

Back
Top Bottom