Getting a parameter from a form into a Report RecordSource

U

Url Onz

I have a stored procedure that I want to use for the
record source of a form. I can put the record source in
the properties box as "Exec ip_rpt 12345" where "12345" is
the parameter I am passing. Now what I need to do is to
get a simple way to pass the parameter to the proc. It
would be nice to get it from a form. I could then code a
comanc button to open the report.
 
A

Andy Williams

Set the recordsource of the report to be the stored procedure. Then put the
parameter value you would like to pass in the Input Parameters. Remember,
if you're referencing a control on another form (which you are) you need to
specify that form's name.

Record Source: ip_rpt
Input Parameters: Forms!SomeForm!SomeTextbox

You may have noticed that when you run a report based on a parameterized sp,
the report will prompt you for those values before generating the report.
The Input Parameters property does that for you.

Andy-
 
G

Guest

I never thought of that. I did it by putting the
RecordSource code in the Report module. I'll try your way
too. It looks more elegant.
Here's what I put in the mod:
Private Sub Report_Open(Cancel As Integer)
Dim cn As String
cn = Forms!frmOlderCaseJobOffer!txtCN.Text
Me.RecordSource = "Exec ip_rpt " & cn
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top