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

Quick Report Button on Form

Status
Not open for further replies.

sandingdude

IS-IT--Management
Jun 26, 2002
109
US
I have a form that i need to put a button on to build a report based on criteria i set in a quesry. I want to reduce the manual labor of going into the criteria of a query and then going to the report. I would like to put an option box in a form that will set the criteria within a query then hit a button to run a report.

The report I am running is just a list of names that donated to our charity in a particular month. We are using Between #10/1/2004# And #10/31/2004# as the criteria with our query.

Any thoughts are greatly appreciated.
 
well, if you have the values for the query on the form, you can make a parameter query that takes values from the form and use that as the recordsource for the report. you would have something like:
select field
from table
where field = forms!frmName.controlOnForm;
if you just want buttons or boxes that the user ticks off, put some code behind the button that checks which options are selected, and based on those opens the report.
did i get the idea?
 
Thanks Spizotfl

I have a contact database with addresses and phones, etc.

I created a report called statement and made a preview report button on the form for the report. I want it to print that report only for that contact when I'm on that contact instead of printing the report for all my contacts. Essentially its applying a filter in the query for that contact.

Any ideas on how to do this?

Thanks
 
Have a look at the 4th argument of the DoCmd.OpenReport method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV

Thank you for your post. Can you point me the direction to get that setup. This is the part of Access I get confused about. For example - I have a button that opens a report - how can I set and where do I set the parameter to open the report for only the record I'm working with.

Thanks
 
Here is my code:

Private Sub statement_Click()
On Error GoTo Err_statement_Click

Dim stDocName As String

stDocName = "Statement"
DoCmd.OpenReport stDocName, acPreview

Exit_statement_Click:
Exit Sub

Err_statement_Click:
MsgBox Err.Description
Resume Exit_statement_Click

End Sub
 
DoCmd.OpenReport stDocName, acPreview, , "[primary key field]='" & Me![primary key control] & "'"
if the PK field is defined as numeric then get rid of the single quotes.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV

My primary ID field is "ID". The issue I'm having is the report is based off 2 linked tables with the same primary id field name.

Any ideas?

Thanks
 
PHV

Another question?

Is me! a function? Or do I need to change that? Also what is the primary key control?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top