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

I have a report that uses an underl 1

Status
Not open for further replies.

Keetso

Technical User
Nov 18, 2003
49
CA
I have a report that uses an underlying select query (which is based on a crosstab query).

This report allows the user to generate sales figures for all salespeople within the company for a selected month. The user gets prompted to enter a month (1-12).

For example, we have 100 salespeople in our company and 25 of them had sales for November. When an end user runs the report they are prompted to enter a desired month. In this case, 11. The report then lists ALL 100 salespeople but only the sales figures for the 25 who had sales in November. The other 75 salespeople who had no sales for that month are zeros.

The report works perfectly but what I'm having trouble with is that I want to put &quot;For the month of: <whatever month was selected>&quot;. I'm getting an error because the underlying select query returns records for ALL salespeople and thus the &quot;month&quot; field would, in the above example, have either &quot;11&quot; for those with sales activity OR would be null for the other salespeople who didn't have sales that month.

I've tried to use the crosstab query results for the &quot;month&quot; field since those records return only those records for salespeople who had sales for that month and thus its &quot;month&quot; field would have only &quot;11&quot;.

In an unbound text box on the report in the ControlSource property I put &quot;=[crosstab query name]![field name]&quot; (without the quotes) and the same as above but with a period instead of an exclaimation point. Both ways gives me errors.

Would anyone have any suggestions as to what I'm doing wrong?

Many TIAs

K



 
It would help to see your query SQL. I think you can add a column in the query
MyMonth:[enter a month (1-12)]
and set this to Row Heading. You should now be able to reference MyMonth as the field in your expression.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Hi Duane.

Yep. That did it. I created a field in the select query called &quot;MonthSelected&quot; and set it up as follows:

MonthSelected: NZ([Month],[For Which Month? (1-12)])

Thus my &quot;month&quot; field remained as normal (only those with sales activity during the month selected had a value in this field with the remaining ones as NULL. &quot;MonthSelected&quot; now has the month that was selected showing on ALL records. I can now reference the &quot;MonthSelected&quot; field in the unbound text box's CrontrolSource property like so: =MonthName([MonthSelected]) and the selected month's name is spelled out.

I didn't know that you could use the parameter input as a condition like that.

Thanks alot for your guidance!

K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top