# Thread: 'greater than' problem

1. Registered User
Join Date
Sep 2006
Posts
10

## Unanswered: 'greater than' problem

hi,

im having trouble setting up a query in a sports day database i have to complete for school. in a form i have a combo box which allows the user to select an age group. a query is then performed using the selected age group and a report generated. the agre groups are under 13s, under 14s, under 15s, under 16s and open (open is anyone over 15 years old). the query for under 13 to under 15s works fine, however im not sure how to get the 'open' query to work. in the combo box i have the value for 'open' set as '>15', but access doesnt seem to like this and no records are selected from my tables, even though i have entries who have an age greater than 15.

does anyone have an idea how i can solve this? i would prefer to use just one query which gets an age group from a form rather than have an individual query for each age group.

thanks!

2. (Making Your Life Easy)
Join Date
Feb 2004
Location
New Zealand
Posts
1,475
Question how are you storing the value

is the age a feild is a text feild or number feild

or

are caluateing base on the brith or the person

3. Registered User
Join Date
Sep 2006
Posts
10
the age is calculated by the date of birth of the person, but the query i am using just displays the age.

4. Registered User
Join Date
Jul 2004
Location
Southampton, UK
Posts
368
What formula are you using to calculate age ?

5. Registered User
Join Date
Sep 2006
Posts
10
it just subtracts the birth date from the current date and divides by 365.2425.

but the formula works out the ages correctly, the 'greater than' sign just isnt being interpreted by ms access correctly.

6. Registered User
Join Date
Jul 2004
Location
Southampton, UK
Posts
368
Are you able to post a sample of your d/b ?
Chris

7. (Making Your Life Easy)
Join Date
Feb 2004
Location
New Zealand
Posts
1,475
Cool What about writing a function To display the Groups

Code:
```Function Age_Group(age)
Select Case Age
Case 0 to 12
Age_Group ="Under 13s"
Case 12 to 13
Age_Group ="Under 14s"
Case 13 to 14
Age_Group ="Under 15s"
Case 14 to 16
Age_Group ="Under 16s"
Case Else
Age_Group ="Open"
End Select
End Function```
Code off top of head

Mite need to play a round the the Case ??

to use

paste code into module
in Query

My_Group:Age_Group([age])

8. Registered User
Join Date
Sep 2006
Posts
10
awesome, it works! thanks myle!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•