Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Charts in Access


Message #1 by "Pam McMillin" <pmcmillin@m...> on Wed, 28 Aug 2002 22:44:51
I am having a difficult time getting a chart in Access.  I have to do some manipulating of the 
data to get the values I want to plot.  But I can't get two series to plot on the chart.

Any help would be greatly appreciated.

Thanks
Message #2 by "Steven White" <Steve.White@m...> on Sat, 31 Aug 2002 12:08:45
Yes, charts in Access are terrible - they don't have the flexibility of those in Excel, and while it 
might be possible to create a chart showing what you want in Excel, it won't necessarily 
translate to Access. 

Given that - if you play around enough with it enough - you should be able to get 2 series to 
work.

Basically what you'll need the Row Source for the chart to be is along the lines of

Axis, Series1, Series2

so - say you want age groups spilt by gender, you get

AgeGroup        Male        Female
0-14                 12                15
15-24               16                45
25-34               15                  6

Which you could get from a rather complex query such as:

TRANSFORM Count(tbl_demographic.id) AS CountOfid
SELECT 
IIf((DateDiff("yyyy",[DOB],Now())<15),"0-14",IIf((DateDiff("yyyy",[DOB],Now())<25),"15-24",IIf(
(DateDiff("yyyy",[DOB],Now())<35),"25-34",IIf((DateDiff("yyyy",[DOB],Now())<45),"35-44",IIf((
DateDiff("yyyy",[DOB],Now())<55),"45-54",IIf((DateDiff("yyyy",[DOB],Now())<65),"55-64",IIf((D
ateDiff("yyyy",[DOB],Now())<75),"65-74","75+"))))))) AS [Age Group]
FROM lookup_sex INNER JOIN tbl_demographic ON lookup_sex.Code = tbl_demographic.SEX
GROUP BY 
IIf((DateDiff("yyyy",[DOB],Now())<15),"0-14",IIf((DateDiff("yyyy",[DOB],Now())<25),"15-24",IIf(
(DateDiff("yyyy",[DOB],Now())<35),"25-34",IIf((DateDiff("yyyy",[DOB],Now())<45),"35-44",IIf((
DateDiff("yyyy",[DOB],Now())<55),"45-54",IIf((DateDiff("yyyy",[DOB],Now())<65),"55-64",IIf((D
ateDiff("yyyy",[DOB],Now())<75),"65-74","75+")))))))
PIVOT lookup_sex.Description;


Where you have 2 tables - tbl_demographic which has fields DOB (Date), SEX (1 or 2) and id 
(Anything, but in my case, autonumber)

and a lookup table lookup_sex which has fields Code and Description (eg 1=Male, 2=Female)

I know that's a damned ugly query, but it's the only example I have at hand which does what 
you're after

Steven

  Return to Index