I have set up a task scheduler to automatically run a macro to call a VBA script to email a report.
I have set up the task scheduler as follows
This appears to be working correctly as it does open the database
I have then set up a macro and dont know how to link the macro to the VBA
Macro as the macro keeps saying it does not recognised lupin so it is not seeing the email address
The VBA code which I found online I have placed in module 1 and is as below. I do not know whether I have adapted correctly and maybe this is why the macro cannot see the arguments.
I have found the following code to attach a report, but I dont know whether I have adapted correctly or where to place it
I am very familiar with VBA in Excel but this is new territory for me with Access. I would be grateful is someone would highlight where I have gone wrong.
I have set up the task scheduler as follows
Code:
Action - Start a program
Program/Script - "C:\Users\User\Desktop\CIS Database.mdb"
Argurments -/x ReviewDate
I have then set up a macro and dont know how to link the macro to the VBA
Macro as the macro keeps saying it does not recognised lupin so it is not seeing the email address
Code:
Action - RunCode
Function Name = ReviewDate ([EMAIL="lupin@uwclub.net"]lupin@uwclub.net[/EMAIL], Overdue or DueReview Dates, Please find attached Review Report)
Code:
public Function ReviewDate( _
MessageTo As String, _
Subject As String, _
MessageBody As String)
' Define app variable and get Outlook using the "New" keyword
Dim olApp As New Outlook.Application
Dim olMailItem As Outlook.MailItem ' An Outlook Mail item
' Create a new email object
Set olMailItem = olApp.CreateItem(olMailItem)
' Add the To/Subject/Body to the message and display the message
With olMailItem
.To = MessageTo
.Subject = Subject
.Body = MessageBody
.Send ' Send the message immediately
End With
' Release all object variables
Set olMailItem = Nothing
Set olApp = Nothing
End Function
I have found the following code to attach a report, but I dont know whether I have adapted correctly or where to place it
Code:
DoCmd.SendObject acSendReport, "RptTrainingDueReviewDate", acFormatXLS