Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to use windows scheduler

137 views
Skip to first unread message

Wayne-I-M

unread,
Oct 23, 2007, 10:52:05 AM10/23/07
to
This seems to get asked quite a bit so here is just one method there are
others (you can create bat files to run “stuff”)

You have a macro that sends e mail reports each night/week/month/etc
You want to backup your database every night
You need to run reports every day showing the daily details for yesterday
Etc
Etc.
Basically you can run any macro at any time.

I have given a macro to open a form with a countdown (using the form's
OnTimer) and then qut access - just as an example
__________________________

Create a new form (call it MyNewForm)
On the form create a new Text box (call it Timer)
Set the font size to 36 (or bigger if you want)
Set the Default value to 10
Put the text box in the middle of your form.
Make the form a popup
On the format column set all these to no or neither
Scroll bars, record selector, navigation buttons, dividing lines, etc, etc –
basically you just want a blank popup with nothing else. (oh all this is not
really import it just looks better).

Click View
Click Code
Cut and paste this

Private Sub Form_Load()
DoCmd.Maximize
Me.Detail.BackColor = vbWhite
End Sub

Private Sub Form_Timer()
If Me.timer = 0 Then
Call Quit
Else
Me.timer = Me.timer - 1
End If
If Me.timer = 7 Then
Me.timer.BackColor = vbRed
Me.timer.ForeColor = vbYellow
End If
If Me.timer = 6 Then
Me.timer.BackColor = vbYellow
Me.timer.ForeColor = vbRed
End If
If Me.timer = 5 Then
Me.timer.BackColor = vbGreen
Me.timer.ForeColor = vbVlue
End If
If Me.timer = 4 Then
Me.timer.BackColor = vbBlue
Me.timer.ForeColor = vbGreen
End If
If Me.timer = 3 Then
Me.timer.BackColor = vbMagenta
Me.timer.ForeColor = vbCyan
End If
If Me.timer = 2 Then
Me.timer.BackColor = vbCyan
Me.timer.ForeColor = vbMagenta
End If
If Me.timer = 1 Then
Me.timer.BackColor = vbWhite
Me.timer.ForeColor = vblack
End If
End Sub
‘end of code’

Again all the colour changes are not really needed – just looks a bit
strange – so worth it.

__________________________
Next create a new macro
Call it TimerMacro
As you can see this is not an autoexec macro (Press F1 for details)
Action = OpenForm
FormName = MyNewForm.
Save and close

__________________________
Click start
Click Control Panel
Click Scheduled Tasks
Click “Add Scheduled Task” or click “New”
Click Next
Select MS Access from the list
Inset a name you will remember (like Daily print or report e mails)
Select Daily
Set the time for around 10 mins from now (you can change this later)
Enter your user name and password (twice)
Note this is the same password you use when you log on
Select the “open advanced properties when I click finish” (tick the box)
Click Finish

You will see a box with where you need to put in 2 paths
Bit of a cheat here
Leave the box open and click Start – then click Run
Now Browse to your database (you need to select All Files in the dropdown)
Select your database
Then simple cut the path from the Run Box
It may look something like this

"S:\NEWVENTURE\Copy (7) of AccessTrek.mdb"
Add /X MacroName to the end of the path
In this case it will be
/X TimerMacro
It will now look something like this
"S:\NEWVENTURE\Copy (7) of AccessTrek.mdb"/X TimerMacro
New cheat here
Paste this into a blank word DOC (just for now)
Next go back to the Start
Click Run again
This time you want to browse to the MS Access EXE
Normally this is in something like
C drive
Programme Files
Microsoft Office
Microsoft Office 11
Then select the access icon
(It may be in a different location on your machine)
Cut the path from the run box
Paste it into your Word DOC – “IN FRONT” of the path to the database
So it will look something like this
"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
"S:\MyDocuments\MyDeadGoodDatabase.mdb"/X TimerMacro
IMPORTANT – this is all on one line with a gap between
\MSACCESS.EXE" "S:\MyDocuments\
Note the gap ?
Next paste this one line into the Run Box in the scheduler
In the start in box you need the path to the programme to run the whole
thing in
It should be the same as the 1st section of the path to the macro
It may look something like this
"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
Click apply and close down all applications. (just like you would at night)
Watch the screen at the time you set the scheduler to run.
Note that part of the code (“quit”) for the form will close and access after
the timer has run.

Last but not least – change the name of the macro to what you want and it
should be OK.

Hope this helps


--
Wayne
Manchester, England.

0 new messages