By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,533 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

Age Ranges

P: 2
Hey guys, have 2 issues I can't seem to find the answer to.

1. I have combo boxes on a form that filter a table via a query. One of the fields contains clients ages. I need a combo box to display age groups (under 18, 19-25, 26-35 etc.) and filter the table accordingly but can't seem to find a way to group the individual ages into these categories.

2. Optional ComboBox Filtering

Thanks in advance for any help.
Aug 1 '10 #1
Share this Question
Share on Google+
2 Replies


Delerna
Expert 100+
P: 1,134
1
You need a calculated field in the query that the form is bound to
Expand|Select|Wrap|Line Numbers
  1. select iif(age<18,"Under 18",
  2.           iif(age>17 and age<26,"19-25",
  3.           iif(age>25 and age<36,"26-35","etc"))),otherFields
  4. From theTable
Now you can use the selected value in the combobox as a criteria for that field.


A neater way if your age groupings allow for it would be to do something like

take the integer of the age divided by 5 to represent the age group
...
...
13/5= 2
14/5= 2
15/5= 3
16/5= 3
17/5= 3
18/5= 3
19/5= 3
20/5= 4
21/5= 4
...
...

Now your combobox needs two fields from a table or query
Expand|Select|Wrap|Line Numbers
  1. Group  Display
  2. 3       15-19
  3. 4       20-24
  4. 5       25-19
  5.  
and you use the group from the combo
as a criteria for the int(age/5) field
Aug 2 '10 #2

NeoPa
Expert Mod 15k+
P: 31,769
If you build your ComboBox to have multiple columns then you can build a filter from the values of the respective lower- and upper-end columns using the format :
Expand|Select|Wrap|Line Numbers
  1. [FIELD] Between {LowerVal} And {UpperVal}
Aug 2 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.