Link to home
Start Free TrialLog in
Avatar of Queennie L
Queennie L

asked on

Execute a command button in MS Access using Task Scheduler

I want to schedule a onclick event command button to fire up automatically in MS Access using Task Scheduler.

Please help.

Thank you.
Avatar of Nick67
Nick67
Flag of Canada image

Others will chime in, but MS Access runs from a logged-in user account only.
Getting it to run in a bulletproof fashion via the Task Scheduler is possible but fraught with ways to go wrong.

What is in the OnClick event?
Will Access remain open?
Will the user always be logged on?
Will Access remain the active task?

You need to add a LOT more detail to your question!
You need to add a LOT more detail to your question!
Agree with Nick...

Also note that you must carefully consider what you want to happen if:
The task scheduler fails to run (for any reason)
The code fails to run (for any reason)
The PC is powered down.

Remember that there is no real "notification" in the task scheduler to alert you if something goes wrong...
In some cases you may never know the task failed, ...possibly letting you go for months with invalid data...

JeffCoachman
Avatar of Queennie L
Queennie L

ASKER

Hello Nick,

I have a code in vb.net that use "autoimport" in task scheduler but I don't know how to do this in MS Access.

Code in VB.net:

Private gAutoImport As Boolean

Private Sub frmimport_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load

		If LCase(VB.Command()) = "autoimport" Then
            gAutoImport = True
			Call cmdImport_Click(cmdImport, New System.EventArgs())
			Me.Close()
			End
		Else
            gAutoImport = False
		End If
	End Sub

Open in new window



Then I created a Task to auto run the command button. This how I created in Task Scheduler:

Action Tab:
Start a program

Program/Script:
\\network\applications\Program.exe

Add arguments:
autoimport  =>>> this will click the command button in my Program.exe


I hope this makes sense.

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
...So you need to make sure that you have "rock solid" error handling in all of your code...
I got it working.

Thanks.
Good to hear!

Jim.
Thanks Jim.

I gave you the credit since the video gave me an idea how to fire the command button.

I really appreciate your help.