Parameter query

colmac
StarLounger
Posts: 65
Joined: 01 Apr 2011, 18:43

Parameter query

Post by colmac »

Have a report which has as its data source, a parameter query.

In normal use, the Parameter query is fed by a list box form to pass two values to the query. With help from you earlier, this all works exactly as I want.

I have now created a new form to view individual records. I have a button set with an embedded macro to preview the same report. It works fine but has the extra step that I need to select the two fields - a bank account name bound to a unique numeric ID, and a numeric value of a year (eg 2014 - has to be numeric as statement dates are not exact matches to calender years/months).

Ideally, I'd like the button to create the report in a single stage, taking the account number [tran_acc_no] and the statement year [tran_state_mth] from the current transaction record.

Is there a way to do this simply, or do I need to create a new report with a different data source?

Sorry to keep pestering you guys!

Many thanks Colin

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Parameter query

Post by HansV »

One option is to remove the parameters from the query, so that the report, when opened by itself, displays all records.
Open the report from each of the forms using DoCmd.OpenReport and specify the WhereCondition argument:

Code: Select all

    DoCmd.OpenReport ReportName:="MyReport", View:=acViewPreview, _
        WhereCondition:="AccountID=" & Me.AccountID & " AND Year(TransactionDate)=" & Me.Year
This is just an example, of course.

The other option would be to create two queries and two reports, but that is less attractive in my opinion.

(No need to apologize - helping others is the purpose of Eileen's Lounge!)
Best wishes,
Hans

colmac
StarLounger
Posts: 65
Joined: 01 Apr 2011, 18:43

Re: Parameter query

Post by colmac »

"Where condition" worked perfectly.

Both reports now work as I want.

Thanks