2

I have a label on an Access form. This is a clickable label which will then run an event procedure. This event extracts data and puts it into an excel sheet. A Client has asked for this to be an automatic task running each day without a the user having to go in and run it each day.

enter image description here

I want to create a Windows Scheduler to run this. I have the following

Program/Script : "C:\Program Files\Microsoft Office\OFFICE07\Office12\MSACCESS.EXE"

And for the arguments I have : "\\bkwdc\data\SHARED\Access SQL\Sales Orders.accdb" /Label575

Is it possible to have a command which will open the form and click a label/link?

Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79
user522962
  • 21
  • 1

3 Answers3

2

Clicking on the label is not the only way to start the procedure.

Inspect the label in the design view, in the events tab you should find the name of the macro that is run when you click on it. Once you know which macro it is you can just run it directly, as shown in this question on SO.

In Powershell it's basically only:

$Access = New-Object -com Access.Application
$Access.OpenCurrentDatabase("\\bkwdc\data\SHARED\Access SQL\Sales Orders.accdb", $False, "Password")
$Access.Run("SomeProc")

Another option would be to specify the macro as a command line parameter for Access. According to the documentation that should be the /x parameter.

access.exe "\\bkwdc\data\SHARED\Access SQL\Sales Orders.accdb" /x SomeProc
Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79
1

There are no native windows commands that are able to interact with your application, but maybe the free AutoHotkey can do what you are looking for.

AHK has a very simple scripting language, which is able to interact with windows, like "sendy keystrokes" or "click on stuff". It even doensn't have to be installed on the server, as the scripts can be converted to a standalone EXE file.

bjoster
  • 4,423
  • 5
  • 22
  • 32
-1

You could execute a powershell script (described here: https://social.technet.microsoft.com/Forums/windowsserver/en-US/f07e20d9-cd76-4abc-a813-c586a0898ed3/calling-a-powershell-code-from-access-2010?forum=winserverpowershell) which will start the scheduled task, see: https://docs.microsoft.com/en-us/powershell/module/scheduledtasks/start-scheduledtask?view=win10-ps