date choice

pastorkc

Board Regular
Joined
Jan 29, 2020
Messages
125
Office Version
  1. 2010
Platform
  1. Windows
Is there a way in access either by query or report to have the user select a date range before the query is run? For example the user wants to run a report for a specific fiscal year.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I am not sure if you have hidden things, or my security is clamping down on it, but I am having trouble exposing the Tables and Queries. I am seeing mostly forms and reports.
 
Upvote 0
OK yes, I had the tables and queries hidden. I unhid them for you.
 
Upvote 0
OK, it has been a long time since I have used Parameter Queries.
I think it may not like the fact that it is a calculated field. I will need to play round with it.

The other thing I have done in the past is to make a selection Form, where they enter in all the criteria, the use VBA to dynamically build the SQL code for the query behind the scenes. A bit more labor intensive, but much more dynamic and flexible.
 
Upvote 0
OK, not sure how to do that. I a, just getting back into Access and alot has changed.
 
Upvote 0
Actually, I figured it out. The issue was that your Fiscal_Year calculated field is using ANOTHER calculated field (CalendarMonth).
Access doesn't like the imbedded calculation functions. But it doesn't really need it.

If you change your Fiscal_Year calculated field from:
Rich (BB code):
Fiscal_Year: IIf([CalendarMonth]<7,Year([Date]),Year([Date])+1)
to:
Rich (BB code):
Fiscal_Year: IIf(Month([Date])<7,Year([Date]),Year([Date])+1)
it will give your the EXACT same value, but then allow you Parameter Query to work properly.
 
Upvote 0
Actually, I figured it out. The issue was that your Fiscal_Year calculated field is using ANOTHER calculated field (CalendarMonth).
Access doesn't like the imbedded calculation functions. But it doesn't really need it.

If you change your Fiscal_Year calculated field from:
Rich (BB code):
Fiscal_Year: IIf([CalendarMonth]<7,Year([Date]),Year([Date])+1)
to:
Rich (BB code):
Fiscal_Year: IIf(Month([Date])<7,Year([Date]),Year([Date])+1)
it will give your the EXACT same value, but then allow you Parameter Query to work properly.
Thank you. Then do I do away with the Calendar Month calculation?
 
Upvote 0
No, there is no harm in leaving it if you want to see it.

Just remember that when putting in parameter for a parameter query, if you are putting them on a calculated field, it is best to do all the calculations straight on that field, and not reference other calculated fields within that calculated field.
 
Upvote 0
ok I fixed those queries with that calculated field. But now my combined query is coming back with this error and I fixed the calculation in SQL view.

1689963003193.png
 
Upvote 0

Forum statistics

Threads
1,215,092
Messages
6,123,064
Members
449,090
Latest member
fragment

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top