Mr. Tushar Sharma
Mr. Tushar Sharma

Reputation: 21

Run a SQL Server Agent Job using Microsoft Access or when I get an Email

I have a process where the user goes into an Access database and processes data and when that is finished, the Access process sends an Outlook email to me every time. Is there a way that the Access database can kick off a SQL Server Agent Job or when I get that Outlook email, I can trigger the job?

Thank you!

Upvotes: 0

Views: 313

Answers (1)

ASH
ASH

Reputation: 20342

Maybe this?

Option Compare Database

Private Sub Command0_Click()
    Call runStoredProcfromAccess
End Sub

Sub runStoredProcfromAccess()
   Dim cmd As New ADODB.Command, RS As New ADODB.Recordset, strSql As String
   Dim i As Integer, j As Integer

   cmd.ActiveConnection = "Provider=SQLOLEDB;Data Source=your_server_name;Database=your_database_name;Trusted_Connection=Yes;"
   cmd.ActiveConnection.CursorLocation = adUseClient
   cmd.CommandType = adCmdStoredProc
   cmd.CommandText = "dbo.CustOrderHist"
   cmd.Parameters("@CustomerID").Value = "ALFKI"
   Set RS = cmd.Execute
   Debug.Print RS(0)
   RS.Close
   cmd.ActiveConnection.Close
End Sub

Upvotes: 1

Related Questions