Pause a Loop statement so computer can cool off.

G

Guest

I have a form that runs code with a very long loop - 12 hrs or more on a
Athlon 64 computer. The computer shuts itself off after a few hours and the
only thing I can think of is causing the problem is it is get too hot. Is
there anyway to pause after so many loops to let the CPU cool off?
 
G

Guest

Hi,
To pause code you can open a new module and paste this in it:

Option Compare Database
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Then close and save the module under whatever name you want.
Now anywhere in your code you can use:

Sleep(1000)'would pause code for 1 second

For example:

Me.requery
Sleep(1000)
Me.requery
Me.requery
Sleep(5000)
Me.requery
....
If you want to add the sleep after a specific amount of loops then add a
variable to the loop which increases by one after each run...then include
validation in the loop to check how high the variable is so that it can jump
to the sleep code when it reaches the specific number. I'm not sure if this
will help with your problem, maybe you should ensure that it really is
overheating (install a temp logger or monitor it manually). If it truely is,
then I would strongly suggest installing some additional cooling devices.
HTH
Good luck
 
G

Guest

Hi,
there are a couple of ways to achieve what you want with mixed datatypes in
the first couple of rows. I think access evaluates the first 15 rows and
bases its field datatypes of the findings.
You could however try to manually import this data ones (file--get external
data--link...) then pay attention to the advanced...button on the import
wizard. There you can specify what datatypes to use for what fields. You can
then save this import specification under save as...! If you now want to
automatically import the stuff through code you can use the transfertext
method and specify the import specification you just created in the syntax.
This should make sure that everything comes over ok.
You could also manually import everything through the wizard...then open the
table it created...delete all records out...open the table in design
view...change the datatypes like you want them to be...then use this empty
table also in the transfertext method as a template so that the data will
come in correct.
HTH
Good luck
 

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