Results 1 to 6 of 6

Thread: Query Problems

  1. #1
    Join Date
    Mar 2003
    Posts
    4

    Unanswered: Query Problems

    Can someone help me with these problems?:

    1) I have an update query set up to calculate a person's age, but if i enter a person's date of birth, the DB will not automatically update the age until i run the query, is there a way to have the age done automatically when a DOB is entered?

    2)How do i group ages?
    I want to create 8 groups
    under 11-PeeWee
    11-12-Bantam
    up to over 35
    and so on, how do I do this?

    thanks.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    1) yes

    assuming DOB is the date of birth stored in the database

    select iif( FORMAT([enter date],'MMDD') < FORMAT(DOB,'MMDD')
    , year([enter date])- year(DOB) -1
    , year([enter date])- year(DOB)
    ) as age

    or use Now() instead of [enter date] which i wrote for testing porpoises


    2) yes

    create table agegroups
    ( agefrom smallint
    , ageto smallint
    , agegroup varchar(12)
    )
    insert into agegroups values (0,10,'Peewee')
    insert into agegroups values (11,12,'Bantam')
    insert into agegroups values (13,...

    rudy
    http://r937.com/

  3. #3
    Join Date
    Mar 2003
    Posts
    4
    k, thanks

    but where do I enter that in the database?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    same place you run the query to calculate the person's age

  5. #5
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580

    Access 2000

    If access 2000 create query in design view...

    Then click view>sql

    And paste the code

    Assuming all the right field names exist, click view > design view to return to the query grid and all the tables / any existing relationships should appear...

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    oh

    ah, thanks, garethdart, i forgot this was access

    my bad

    in access you can create/run queries without ever seeing the sql

    thanks for jumping in

    sugetek, you can paste and run only one query at a time

    first the CREATE TABLE, then an INSERT, then another INSERT, etc.

    rudy

Posting Permissions

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