Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EXEC sp_whatever @var_1, @var_2 from Access SQL

Status
Not open for further replies.

CybOrg

Programmer
Nov 30, 1998
57
0
0
SE
I have a large SQL Server database that I access via MS Access. What I'd like to do is execute a stored procedure, passing parameters from a user form. Kinda like:

PARAMETERS Forms!Main!fromdate DateTime, forms!main!todate DateTime;
EXEC sp_Total_Time_For_Period @date1=forms!main!fromdate,@date2=forms!main!todate;

It seems like it ought to be possible but I haven't found any documentation to prove it... Clues anyone? If it isn't possible, please let me know too... ;-)


 
This would be done through ADO using a 'Command' object. You can find good documentation on Microsoft's website.
 
Thanks - Can I use ADO inside Access97, and run a report off the result set?
 
Yes you can use ADO in Access 97. Depending on the way your stored procedure works... if it returns a recordset then you might need to dump the results into a temporary table and report off of that.
 
If you want to return a recorset from the stored procedure, then you can put it in your form recordset object by setting the rst to the cmd.execute

Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset
' your logic to set up the command text
Set rst = cmd.Execute
' now you can work with the recordset
 
You may want to check the article at the following link. It explains "How to Simulate Parameters in an SQL Pass-Through Query."

Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Thanks, all!

Just what I needed!! :-D

/Cy

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top