Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Issue using query information twice in a report
Holly 

16 years ago
I have a table that includes a column for date, bay/dept, and estimated cost.  I created a query that prompts me for the year then month as it opens - it then gathers entries for that month, groups and counts the bay/dept incidents and sums up the estimated cost for those incidents:

SELECT DISTINCTROW qryBayPromptMonthYear.[BAY/DEPT], qryBayPromptMonthYear.Expr1, qryBayPromptMonthYear.Expr2, Sum(qryBayPromptMonthYear.[CountOfBAY/DEPT]) AS [Sum Of CountOfBAY/DEPT], Sum(qryBayPromptMonthYear.[ESTIMATED COST]) AS [Sum Of ESTIMATED COST]
FROM qryBayPromptMonthYear
GROUP BY qryBayPromptMonthYear.[BAY/DEPT], qryBayPromptMonthYear.Expr1, qryBayPromptMonthYear.Expr2;

The report I created from this query automatically prompts me for the year and month upon opening and lists bay/dept, no. of incidents, and estimated cost that month for each bay/dept.  All of this works great.

The issue is when I try to place a pie chart on the report using this same query.  I can put the chart in and make it work, but when I open the report with the chart the report prompts me for the year and month MULTIPLIED by the number of bay/dept's that had incidents for that month (example:  if 3 depts (out of 20) had problems that month - the report will prompt me for the year and month 3 times before it opens).  Without the chart it works fine.  

Do you know a fix for this issue?  

Thank You,
Holly


Answer from Richard Rost:

Here's what I would do:

Make an unbound form that has your criteria on it as unbound fields. So if you have two values (myYear, myMonth) then just make two text boxes.

Now, in your query, use that form for the values:

=Forms!MyFormName!myYear

Now, when your queries and reports run, they'll just get the values from that form and you only have to type them in ONCE.

If you want to refer to a value on a Form, you can use the notation:

Forms!FormName!FieldName

You can use this notation inside of queries, other forms, or even reports. I have a free tutorial that explains how to use this:

http://599cd.com/tips/access/forms-formname-field-notation?key=BlFAlEx

Note that if you're refering to a value on a SUBFORM, the correct notation is:

Forms!FormName!SubForm.Form!FieldName

Crazy, I know. Enjoy! Hope this helps.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/22/2026 4:44:33 PM. PLT: 1s