Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


executing a job from Access Data Project

Posted on 2005-05-02
Medium Priority
Last Modified: 2006-11-18
I would like to accomplish the following in Microsoft Access Project

Created a list box, which holds all the current jobs in SQL Server.

I want to  add a command button ,which on  clicking will execute the selected job by
executing the stored procedure sp_startjob .

Is this possible? Are there any examples that i can look at?

Question by:aswam1975
  • 2

Expert Comment

ID: 13910071
As long as the user has the appropriate permissions, you can use this vb code:

currentproject.execute "EXEC sp_startjob ..."



Author Comment

ID: 13912122
This is what i have done so far:
I have a list called displayJobs.Added a command button called Start Job.To the click  event i have the following.

However i get an error that says " Run time error 3701. Parameter object is improperly defined.
Inconsistent or incorrect information is provided".

The error is at line  .Parameters.Append prm. Can someone point out what i am doing wrong.

Private Sub startJob_Click()

      Dim rst As ADODB.Recordset
      Dim cmd As ADODB.Command
      Dim prm As ADODB.Parameter
      Dim job As String
      Dim numb As Integer

          Set cmd = New ADODB.Command
      numb = displayJobs.ListIndex
          job = displayJobs.ItemData(displayJobs.ListIndex)

      Set prm = New ADODB.Parameter
      prm.Name = "job"
      prm.Type = adVarChar
      prm.Direction = adParamInput
      prm.Value = job
      Set cmd = New ADODB.Command
      With cmd
          .ActiveConnection = CurrentProject.Connection
          .CommandText = "sp_start_job"
          .CommandType = adCmdStoredProc
          .Parameters.Append prm
      End With

         Set prm = Nothing
                Set cmd = Nothing

End Sub

Accepted Solution

paelo earned 135 total points
ID: 13913632
I believe the parameter name you're looking for is called job_name.  Or you can use job_id.


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question