pass parameter from form to report

M

Minal

Hi,

I have a form and report both based on a the same query that asks for a
parameter input.

To open the form I have to input the parameter.
Once the form is open I have a button to print the report on click.
When I click the button it asks for the same parameter.
The code is

Private Sub Command_Click()
On Error GoTo Err_Command_Click

Dim stDocName As String

stDocName = "ReportName"
DoCmd.OpenReport stDocName, acNormal

Exit_Print_Click:
Exit Sub

Err_Command_Click:
MsgBox Err.Description
Resume Exit_Command_Click

End Sub

When I click this command button it asks for the same parameter
information that I have used to open the form.

What I would like for is that the report is printed for the parameter
that was used to open the form.
Can some one please help me.

Thanks
 
J

jahoobob via AccessMonster.com

How is it that you enter a parameter to open a form? Is the query asking for
the parameter?
If the form is first opened and then you enter a parameter, find every place
you have the parameter in the report and replace it with:
[Forms].[the form's name].[the parameter]
If not, we need more information.
 
M

Minal

Hi

I have a table (tbl_Issues) with several feilds. One of the feild is
IssueID (Indexed no duplicates, text feild)
Another table (tbl_IssFolup) with IssueID (Indexed. yes duplicates,
text feild)

Both linked by IssuesID

I have created a query (Qry_Issues) based on this table (tbl_Issues)
with almost all feilds and with criteria that prompts user to enter the
IssueID to pull up record for that IssueID.

Based on this query (Qry_Issues) I have a form (frm_issues) which
opens in edit mode so users can update information in the subform
(frm_IssFolup based on tbl_IssFolup) linked to the main form by
IssueID.

Based on the above query (Qry_Issues) I have also created a report
(rpt_Issues). To open this report the user is prompted to enter IssueID
and the report like the form has a subreport (rpt_IssFolup) linked by
IssueID.


Now the user opens the form (frm_Issues) based on the IssueID entered
in the parameter prompt.
They enter information in the sub from (frm_IssFolup )
save the record.
Now to print the information updated they click on the command button.
they are again prompted to enter the IssueID for which they want the
report to be printed.

the code here is

Private Sub Command_Click()
On Error GoTo Err_Command_Click


Dim stDocName As String


stDocName = "rpt_Issues"
DoCmd.OpenReport stDocName, acNormal


Exit_Print_Click:
Exit Sub


Err_Command_Click:
MsgBox Err.Description
Resume Exit_Command_Click


End Sub


I want to eliminate this repeat entry of IssueId parameter. I want to
print the report for the IssueID for which the current form is opened.

Hope these details help in better understanding my question.

Thanks
 
J

jahoobob via AccessMonster.com

In your code, replace DoCmd.OpenReport stDocName, acNormal
with
DoCmd.OpenReport stDocName, acViewNormal, "", "[IssuesID]=[Forms]!
[frm_Issues].[IssuesID]", acNormal
 
M

Minal

Hi
I did just what you suggested but I still get the promt to enter
parameter value.
What am I doing wrong here?

Thanks for all your help so far.
 
J

jahoobob via AccessMonster.com

Check for spelling differences.
Hi
I did just what you suggested but I still get the promt to enter
parameter value.
What am I doing wrong here?

Thanks for all your help so far.
 

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