A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

creating a form



 
 
Thread Tools Display Modes
  #1  
Old July 9th, 2009, 04:04 AM posted to microsoft.public.access.queries
reportyemi
external usenet poster
 
Posts: 53
Default creating a form

I have a column for patients age on a form that i am creating but during
analysis/ reporting I want to report total number of patints ages in age
ranges like below

10-14;15-19;20-24;25 - 29;30- 34;35 - 39 and so on
no of patients 3 5 54 76 43 21
that is 3 patients had ages between 10 and 14 ..and so on

how can i do this

yemi
  #2  
Old July 9th, 2009, 05:27 AM posted to microsoft.public.access.queries
MGFoster
external usenet poster
 
Posts: 653
Default creating a form

reportyemi wrote:
I have a column for patients age on a form that i am creating but during
analysis/ reporting I want to report total number of patints ages in age
ranges like below

10-14;15-19;20-24;25 - 29;30- 34;35 - 39 and so on
no of patients 3 5 54 76 43 21
that is 3 patients had ages between 10 and 14 ..and so on

how can i do this


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You can use the Partition() function in the report's query, like this:

SELECT Partition(patient_age,10,89,5) As AgeRange, COUNT(*) As Patients,
... other columns, if any ...
FROM table_name
WHERE criteria.... etc. ...
GROUP BY Partition(patient_age,10,89,5)

The Partition() function returns a string like the following:

:10
10:14
15:19
20:24
25:29
.... etc. ...
90:

In the above example, I've set up the Partition() function to only work
on ages between 10 and 89. Every age below 10 will be represented as :9
(i.e., 9, or younger). Every age above 89 will be represented 90:
(i.e., 90, or older).

If you want more "human readable" partitions you could use this formula
(watch out for line wrap):

Replace(Replace(Replace(Partition(Age,10,89,5),":" ," - ")," -
9","below 10"),"90 - ","90 and above")

, which means you'll have to put the same formula in the GROUP BY
clause.

HTH,
--
MGFoster:::mgf00 at earthlink decimal-point net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSlVxxIechKqOuFEgEQK/xgCggwxT8NrKr+Fc1GvkDFWXiJOGnuYAniH7
WYjWGKQUj01A+FhZ+AEimycK
=3Kyk
-----END PGP SIGNATURE-----
 




Thread Tools
Display Modes

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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:48 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.