SunQuest
 
           Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 25th, 2008, 05:23 AM
Birkofas Birkofas is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 16 Birkofas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 46 m 49 sec
Reputation Power: 0
Sorting the age goups

In my query are date of birth and age of pupils. In the report i have show how many pupils for the particular age group like (under 5s, 5-7 or 8-11)coming for visit. I don't know how to connect age of pupils or DOB to any of that age group. Can you help me please?

Reply With Quote
  #2  
Old April 25th, 2008, 08:37 AM
sherrington sherrington is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 84 sherrington User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 58 m 47 sec
Reputation Power: 4
You could put a series of IIFs in your query, e.g.

AgeGroup: iif([PupilAge] < 5, "Under 5", iif([PupilAge] <= 7, "5-7", "8-11"))

Alternatively, you could write a function which does the same kind of thing and use that in the query. If you need to use the Age Group in multiple places in your system, I would recommend the function route as it would give consistenmcy in reporting.

Reply With Quote
  #3  
Old April 25th, 2008, 09:32 AM
dykebert's Avatar
dykebert dykebert is offline
Contributing User
Click here for more information. Click here for more information
 
Join Date: Apr 2008
Posts: 195 dykebert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 1 h 37 m 18 sec
Reputation Power: 1
Yup.
So in your query will look something like this

SELECT <field1>, <field2>, ..., iif([PupilAge] < 5, "Under 5", iif([PupilAge] <= 7, "5-7", "8-11")) AS ageGroup, ....
FROM .....

If your report needs to show each student and then a total of how many are in the group modify your query using the function from Sherrington like so:

SELECT <field1>, <field2>, ..., iif([PupilAge] < 5, "Under 5", iif([PupilAge] <= 7, "5-7", "8-11")) AS ageGroup, ....
FROM .....


and then in the reprort use the ageGroup to Group and put a total in the Group footer.

If you just need a report that has how many students are in each group then the query would look like this.

SELECT Count(PupilAge) AS NumInGroup, IIf([PupilAge]<5,"Under 5",IIf([PupilAge]<=7,"5-7","8-11")) AS ageGroup
FROM <tablename>
GROUP BY iif([PupilAge] < 5, "Under 5", iif([PupilAge] <= 7, "5-7", "8-11")) ;

Reply With Quote
  #4  
Old April 25th, 2008, 10:23 AM
Birkofas Birkofas is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 16 Birkofas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 46 m 49 sec
Reputation Power: 0
Thanks, sherrington and dykebert it working well!!!
It looks very easy, but when you don't know it looks very difficult.
thanks again.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Sorting the age goups


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway