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

Control chart date grouping using VBA?

Status
Not open for further replies.

Smoothcat74

Technical User
Aug 29, 2008
40
0
0
Hi everyone,

I have a report that contains a chart built off of a saved query. The x-axis of this chart is a list of dates. What I would like to do is give the user an option based on a set of radio buttons as to how they would like to group the dates: daily, weekly or monthly.

How would I use VBA to update the grouping of the query/chart prior to loading the report?

Thanks for any help!
 
Capture the date ranges and use them in a BETWEEN clause in the source query. You will probably need to copy the SQL, modify it, and assign it to the Chart's RowSource property
before the chart opens. Are you calling the report from a form?

Cogito eggo sum – I think, therefore I am a waffle.
 
I'm not sure you need any code. Assuming a form named "frmRptCrit" with an option group named "opgDateInterval" with options like:
[tt]
1 Daily
2 Weekly
3 Monthly
4 Quarterly
[/tt]

You can create a derived column in a query with an expression like:
Code:
XAxis: DatePart(Choose([Forms]![frmRptCrit]![opgDateInterval],"y","ww","M","Q"),[OrderDate])

Duane
Hook'D on Access
MS Access MVP
 
I always do it the hard way. Nice catch, Duane!

Cogito eggo sum – I think, therefore I am a waffle.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top