I have been trying to pull this off and maybe I am getting close. I have some code in Access I need to Run at a specific time of day. I do not want to use Windows Task Scheduler
How about you use a static date variable:
static dateRan as date
if dateRan = Date then exit Function
If RunDateFormat = ("15:30:00") Then
dateRan = date
'Call these codes and other stuff in here
End If
This way you could keep it running overnight and it will work the next day assuming no error occurs to halt operation.
As I'm sure you're aware, doing a scheduled task through Access requires the form to be up and running so you have a fairly large opportunity to fail to run the your time sensitive task. I really do recommend using the task scheduler if it is feasible.
As hinted at by HelloW, I wouldn't go with every second for checking unless it is critical that the code run about the right time. If it is critical, you may want to do some checks and modify the timerinterval programmatically.
Like so:
If Hour(Now) < 14 or Hour(Now) >= 16 then
me.TimerInterval = 3600000
else
me.TimerInterval = 30000
end if
You could narrow it down more, to where you have the checks run more often the closer you get to the time you need to run your time sensitive code.