Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error when executing a job from MSAccess

Posted on 2013-06-20
19
Medium Priority
?
460 Views
Last Modified: 2013-06-21
Hello.

I have a customer who has an Access application.  

The last step of the Access application needs to start a job in SQL server.

This is what I have in my pass-through query:

SET NoCount ON ;


EXEC msdb.dbo.sp_start_job N'Upload_Book_Titles';

I get this error:

Pass-through query with ReturnsRecords property set to True did not return any records.

I have tried including a DoCmd.SetWarnings =False;- this does not work.

I do not see any default setting within my ODBC connection that I can update to resolve this error.

What command can I include in my pass-through query to resolve this error, execute this job, and complete my task?
0
Comment
Question by:programmher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 9
19 Comments
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 39265005
You have to specify in the properties of the PT Query that it is not returning records.

/gustav
0
 

Author Comment

by:programmher
ID: 39265056
gustav,

Not sure what you mean.

I run this command from the SQL window and it executes.  It is just running it from Access that gives the error.
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 39265079
I don't know. You have:

> .. ReturnsRecords property set to True

But:

 sp_start_job N'Upload_Book_Titles'

doesn't look like it is returning records.

/gustav
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:programmher
ID: 39265173
Ok- I understand your comment now.

The job that the Access app is calling inserts records from an Excel spreadsheet into the SQL table.  So, technically, the query is not returning any records back to the Access app - the customer requirement is to insert records from the spreadsheet into the SQL table.

Is there a command I can use to turn off this error message?
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 39265206
OK, but "returns records" in this context is relative to Access.
So I would try running it with ReturnsRecords property set to False.

/gustav
0
 

Author Comment

by:programmher
ID: 39265218
How would I do that?

I tried DoCmd.SetWarnings False and that did not work.
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 39265227
1. Open the query in designview.
2. Set property ReturnsRecords to False
3. Save and close the query.

/gustav
0
 

Author Comment

by:programmher
ID: 39265320
I now get an error - "Incorrect syntax near ReturnRecords"

My code:

SET NoCount ON ;

EXEC msdb.dbo.sp_start_job N'Upload_Book_Titles';

ReturnsRecords = False;
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 39265338
Yes. It is not an SQL statement.

It is in the property sheet of the query in Access this setting exists.

/gustav
0
 

Author Comment

by:programmher
ID: 39265889
ok - thanks.

I will create a separate function for this.

I thought there was a way to test the pass-through query by running it from the access query list.
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 39265910
There is. You just double-click it and it will run.

/gustav
0
 

Author Comment

by:programmher
ID: 39265990
When I double click the pass through query, I get the error I included in this incident.
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 39266006
But did you change the property?

/gustav
0
 

Author Comment

by:programmher
ID: 39266213
I am creating a function to include the other logic you recommended and change the property.


Did I misunderstand your recommendation?
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 39266229
I think so. No code involved, just setting the property of the query.

/gustav
0
 

Author Comment

by:programmher
ID: 39266284
Confused.

This is how my pass-through query looks from the SQL view on MSAccess:

SET NoCount ON ;

EXEC msdb.dbo.sp_start_job N'Upload_Book_Titles';

When I try to run this from MSAccess, it asks for the password (which I enter) then I get the error.

when I include a line to set the ReturnsRecords = False, I still get an error.

Do I need to include something other than "ReturnRecords = False"?
0
 
LVL 51

Accepted Solution

by:
Gustav Brock earned 600 total points
ID: 39266321
There is no line or code to insert.

When in designview, go to the Properties' Sheet.
Locate property ReturnsRecords.
Set this to No.
Save the query.

/gustav
0
 

Author Comment

by:programmher
ID: 39266925
I understand.

Thank you for your patience and for your help.   That resolved the issue.   I was able to execute the SQL job from my Access application.

I am now working on my customer being able to execute this pass-through query using a button that will connect to the SQL database via ODBC connection, log in with the password, and complete the task.

Thank you again!!!
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 39266981
You are welcome!

/gustav
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

721 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