How to pass parameters to a report

R

RS

I am new user and do not know much about Access Programming. I have a form
where I have a number field called memberid. I have created a report called
member report which works baed on memberquery. Which is baed on a query
memberquery. I have a form which fromupdate . I want to put a command button
on this page. I want this command button to read value from memberid textbox
and generate the report for only that member.

I have parametrized the query and it asks me enter memberid and then
genrates the report for that member.

I want this to happen just by clicking that button. It should be able to
read memberid field value and create report for only that member. I do not
want a dialogbox to appear asking me the memberid.

Thank You in advance.
 
D

Duane Hookom

I would modify the code in the command button like:

Dim strWhere as String
Dim strReportName as String
'assuming a numeric field named "MemberID"
strWhere = "[MemberID] = " & Me.memberID
strReportName = "Member Report"
DoCmd.OpenReport strReportName, acViewPreview, , strWhere

Then, make sure you remove the parameter prompt from the query.
 
A

Armen Stein

One way to have a report prompt the user for criteria before it runs
is to open a form from the report's Open event. Open the form in
Dialog mode so that the report waits for the form to be closed or
hidden before it proceeds. That way you can collect criteria from the
user and build a Where clause for the report. It also means that you
can call the report directly - you don't need to call it from a form.
And the selection form is reusable - it can be called from multiple
reports if they need the same criteria.

I've posted examples of this technique on our J Street Downloads page
at http://ow.ly/M58Y
See "Report Selection Techniques".

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 

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