Timer function to save file with date&time

  • Thread starter Thread starter fincenobite
  • Start date Start date
F

fincenobite

Hi,

Using timer function in Access to save info from Oracle database for
statistics.

Problem:

Trying to set up timer function so that it will save query results
every morning at the same time. How will I do this? Will it work if I
have timer interval 24 hours between?

I have created macro to save the query results to folder, but how can I
add date&time to the save file? Otherwise I will get error message that
the file already exists and access will halt.

All help is welcome.

br, Miikka
 
Hi,

First alternative,

Use a timer interval of, say, 10000 (10 sec), and check the system date and
time against a pre-set value. Example:



Dim nextSaveDue As Date
...
' initialize the value, once
nextSaveDue = Now() + 1 ' one day after now, now=date AND time

and, in the timer handling procedure:


if( Now <= nextSaveDue) return
... do the save ...
nextSaveDue=Now+1



You can also use a user defined database property, instead of a VBA
variable, so its initial value would exist (no need to explicitly set an
initial value, like I shown) but the main point is that the FORM has to be
alive, at some point.


A second alternative is to use the built-in OS job scheduler and, from
there, lunch an Access application with a command line implying a macro (/X
option), and this macro does the job you want to do. The job scheduler can
be set to repeat the lunch every day, at a given time. This solution does
not required timer, neither that the application is already up and running,
but you probably need to touch the PC to set its job scheduler (plus the
standard deployment of the Access application)



Hoping it may help,
Vanderghast, Access MVP
 
Back
Top