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

Basic Report Generation Question

Status
Not open for further replies.

KeyserSoze1877

Programmer
Sep 6, 2001
95
US
I have a combo filled by a query on a form.
I have a button to preview a report that is linked to a query with a user input field for a where clause.

How do I use the combo box for the report generation?

Basic and simple.

The table contains a disc catalog and I want to generate a report for what disc is chosen.
 
Maybe someone might have an easier method, cause I only know how to do it with code:

Dim qDef As QueryDef

Set db = CurrentDb
Set qDef = db.QueryDefs("NameOfYourQuery")
qDef![ParameterName] = YourComboBox.Column(BoundColumn,YourCombobox.Listindex)

"Set report query to " = qDef.OpenRecordset()

 
1st: Build your report or catalog based on a seperate query.

2nd: Open your report query in design mode and then where it says criteria (for the report name field) right click on your mouse and then select build and then choose expression. Choose form on the left hand side and expand the form that has the combo box name and then in the middle pane pick the field name of the combo box. When done press ok.

3rd: On the combox set the after update event to run that report.

Done.

:)WB
 
A slightly different approach:

1. Base your report on a query to select a disc from the table.

2. In your query specify the form and the combo box field as a criterion in the query. For example, if you name your form frmDiscs and the combo box on it DiscName, your query criterion will look like:
[Forms]![frmDiscs]![cboDiscName].

2. Attach code or macros to the open and close events of the report to open and close frmDiscs.

When the user previews the report, your form will open. When the user clicks a choice, the query will run and fill the report.

 
On Button Click
Dim stDocName, ExprDisc As String

stDocName = "Report Name"
ExprDisc = "[DiscName] = '" & Combo4.Column(BoundColumn,
Combo4.ListIndex) & "'"
DoCmd.OpenReport stDocName, acPreview, "MasterList
Query", ExprDisc


This works the best, the OpenReport function allows to finish WHERE clauses.

Thanks for the steer in the right mode of thinking.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top