How do i increase values in an update query?

C

Carrotsinapod

Is there any way to increase a value in an update query? I want to change all
people in year 7 to the year above, e.g. year 8, in an update query, but I
don't know how. Thanks for your help.
 
M

Marshall Barton

Carrotsinapod said:
Is there any way to increase a value in an update query? I want to change all
people in year 7 to the year above, e.g. year 8, in an update query, but I
don't know how.


There may be something wrong with your table design since
this kind of operation should not be needed. (It sounds
just like the problem of storing people's ages rather than
their birthdate.)

However, you can do what you asked by using an Update query.
(Be sure to make a backup before doing this so you can
quickly recover from any mistakes.)

UPDATE table
SET yearfield = yearfiueld + 1

Be very careful that you do not run that query twice.

If you really only want to update the yearfield when it was
7, then add a where clause:
WHERE yearfield = 7
 
T

t t via AccessMonster.com

if you have any field as year you can update it referencing current date
and birthday.

create an update query and select only field year. at query update line
write Format(date();"yyyy")-Format([birthday];"yyyy") and run query.

you can run querry whenever you want . because it never makes mistakes
gives true results.
 
M

Marshall Barton

t said:
if you have any field as year you can update it referencing current date
and birthday.

create an update query and select only field year. at query update line
write Format(date();"yyyy")-Format([birthday];"yyyy") and run query.

you can run querry whenever you want . because it never makes mistakes
gives true results.


Sorry, but I fail to follow the significance of this
message.

If it's in response to my comment about storing people's age
instead of birtdate, whatever you're trying to accomplish
here would still have to be executed everyday to keep the
age field accurate.
 
Top