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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a report from an Access 2000 project

Status
Not open for further replies.

batteam

Programmer
Sep 12, 2003
374
US
I have a simple report with a simple 'Select' stored procedure as the record source. However, before the report can run, it needs a parameter from an Access Project form. In my case, the parameter is an employee id number. The user enters an employee id unto the form, then the report is run via the 'DoCmd.OpenReport' method when the user clicks 'View Report'. I have my stored procedure written to select that employee id record from a table, but my stored procedure is not getting that employee id data from the form. I keep getting the pop-up message parameter box asking me for the employee id number. The stored procedure and report both work fine once I supply the employee id manually, but it will not 'grab it' from the form automatically when the report is run. I have tried multiple variations of sending the paramater over to the procedure, and these all work fine on other processes (e.g. Update, Insert Into, etc. stored procedures).

How does one set up a stored procedure, used as a report's record source, to get the required parameter from a form when the report is run?? This all worked great with Access .mdb files and sending parameters over to record source queries, but obviously something is different with Access projects.

Thanks in advance for any assistance you can offer.
 
On the data tab along with the record source is an "input parameters" property. Assuming there is a Form open with the ID.
@ID=Forms!SomeForm!ID
 
Thank you very much 'cmmrfrds'. This does work. NOW I see how the relationship between forms, stored procedures and REPORTS work. When using reports, the REPORT gets the parameter from the form and then the REPORT passes it back to the stored procedure. I do not have any code behind my form that in any way references the stored procedure used as my report's record source so this is the only way that stored procedure can get the parameter. I always thought that stored procedures could only take parameters from forms. Next, I want to experiment with sending over up to three parameters and putting them in that "input parameters" property box. For instance, the CustomerID and two date fields - like beginning and end dates. If you know this won't work (i.e. the input parameter property will only take ONE parameter, let me know).

Again, thank you very much for taking the time to help me out.
 
You can string mulitple paramters in the input parameter property. I sometimes use public variables or functions to supply the parameter instead of from an open Form.

In standard module.
Public begDate as Date

Public Function ReturnBegDate() as Date
ReturnBegDate()
End Function

In Form some place.
begDate = date from a textbox

On data tab,
Input Parameters = @begDate=ReturnBegDate(),etc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top