Run Access Macro Automatically

UnysonElliot

New Member
Joined
Jul 21, 2014
Messages
31
Hello,

I have created a database that I would like to put on a schedule to send out every day without manual intervention. I have seen a lot of posts from various websites about using Windows Task Scheduler. I cannot figure out how to use the Windows Task Scheduler. I was coming here either for help with setting up Windows Task Scheduler to run this macro or if there are any other solutions that anybody knows.

Let me know if you need any info from me that I can provide to help.
 
Just an FYI some vba or VBScript code can be run this way:
Code:
    Set app = CreateObject("Access.Application")
    app.OpenCurrentDataBase "C:\myTemp\db1.accdb"
    call app.Run("TPCReport")
    app.Quit
    Set app = Nothing

Where TPCReport is the name of a sub/function in a public module in the access database. Per the discussion above you can say that the database is technically opened, but it is done so invisibly to the user and is closed when the subroutine returns.
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Just an FYI some vba or VBScript code can be run this way:
Code:
    Set app = CreateObject("Access.Application")
    app.OpenCurrentDataBase "C:\myTemp\db1.accdb"
    call app.Run("TPCReport")
    app.Quit
    Set app = Nothing

Where TPCReport is the name of a sub/function in a public module in the access database. Per the discussion above you can say that the database is technically opened, but it is done so invisibly to the user and is closed when the subroutine returns.

So here is what my current module says.

Public Function Elliot()
Dim Current_Date As String
Dim File_Name As String
Current_Date = Format(Now(), "yyyymmdd")
File_Name = "T:\GLOBAL INDUSTRIAL\Global Invoice Report\Reports\Global Invoice Shipment Report " & Current_Date & ".xlsx"
DoCmd.TransferSpreadsheet acExport, , "Global Invoice Shipment Report", File_Name
End Function

Am I adding your script somewhere to that or what?
 
Upvote 0
that would be the function you want to call.

So, given my script, more or less it would look something like:
Code:
    Set app = CreateObject("Access.Application")
    app.OpenCurrentDataBase "C:\myTemp\db1.accdb"
    call app.Run("[B][COLOR="#FF0000"]Elliot[/COLOR][/B]")
    app.Quit
    Set app = Nothing

This is code that you you would use to run something in access, when you are somewhere not in access (such as when doing something in Excel, or using a script to run a scheduled task using windows task scheduler).
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,335
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top