Code Question

  • Thread starter Thread starter Ashley
  • Start date Start date
A

Ashley

Is is possibble to program a Form to open at a certain time of the day.....?
If so... How?
 
On Fri, 17 Oct 2008 23:24:37 -0400, "Ashley"

I am assuming the application is already running. Use a timer. Timers
are associated with forms, so you must have some form open at all time
for this to work reliably. If you don't already have that, create a
new form and open it at startup time and keep it hidden (check out the
details of DoCmd.OpenForm in the help file).
Then set the form's TimerInterval to for example 10000 so it ticks
once every 10 seconds. Then in the Form_Timer event write code like:

Const TIME_TO_LAUNCH = #9:00:00 AM# 'Change this to your time.
Const FORM_TO_OPEN = "frmTest" 'Change this to your form name.

If Time = TIME_TO_LAUNCH Then
'If the form is not already open...
If SysCmd(acSysCmdGetObjectState, acForm, FORM_TO_OPEN) <>
acObjStateOpen Then
DoCmd.OpenForm FORM_TO_OPEN
End If
End If

-Tom.
Microsoft Access MVP
 
Yes, the best way is to use an outside scheduler which will run a program or
fire a shortcut. That is because, doing it entirely within Access may be
problematic if the user doesn't have your Access program open. Further, many
outside scheduling programs set a flag, so you can run your code the first
time your system opens, if it hasn't run yet.

Alright, so how do you do it? Actually quite easy if you don't have security
enabled, because you'll need a live person to supply a password if it is.

1. Open your database to the database container window.
2. Drag the form to the desktop, (which creates a shortcut)
3. Find a specific place for the shortcut to avoid accidental clicking
3. Open your scheduler (I use the one in control panel)
4. Find the shortcut file and run through the dialogs.

That's it.
 
Yes AutoIT is an excellent scripting language that will build and run exe's.

In this case, I think the built in scheduler may be better because there
won't be any permissions issues, and it's simple enough for users to do with
any learning curve.
 
Back
Top