Discussion Locked

Access2000 printing rpt from user input

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am trying to print a report based on user input after clicking a command button. Specifically, when the user clicks the command button from the switchboard, it will prompt for input; the user inputs the data, and it will then print the report using the data input by the user.

Thanks!

5 replies

by dwdino

I might be able to help, but need more information.

How is the info entered? (form, popup, etc.)
What is the report based on?

A simple method is:

Dim stDocName As String

stDocName = "issue_print"
DoCmd.OpenReport stDocName, acNormal

This requires you to have a report named "issue_print" and to have that report run a query.

The query uses the following critera:

[forms]![Main]![main_child]![Issue_ID]

in the issue_id field. This pulls the current record which theemployee has open and prints the report.

by it_cowboy

You can create a parameter query to run the report from. This will provide a prompt box for the user to enter something into. Beware though, the input is free text so any incorrect characters will result in an empty report.

The other way is to have a combo box on your form where the user selects a value and the then clicks the command button. You will need to write some code to pass the selected value of the combo box to the report ie:

Assumptions:
1. Report is a monthly report called"MonthlyReport"
2. user needs to select a month in a combo box called "cboSelMonth":
3. Field on the report to filter on is called "Month"

in the OnClick event for the command button, enter the following code...

docmd.OpenReport "MonthlyReport",,,"Month='" & cboSelMonth & "'"

If the month selected in the combo box is May, the "WhereCondition" for the report will be Month='May'.

Your report will open only showing the data where the month field contains the word 'May'

Hope this helps...

This discussion is closed to new replies.