Hi All,

I have a access database with these columns. USER_ID,COUNT,TIMES

Let say the current record is this:

USER_ID,COUNT,TIMES
STEVE20,24,1.5

Now I want to updated the current count record and times, but before updating I want the old record to be added to the new record. What should be my query?

first there shud be an insert query to move ur records to the other table and then an update query

eg.insert into newtablename(col1, col2, col3) select col1,col2,col3 from oldtablename

and then an update query based on userid

update oldtablename set count=value1,times=value2 where user_id="STEVE20"

hope it helps u

hi poojav,

thanks for the reply, yes I already knew that, what I am asking is that for example:

From the record from the starting post,

the new record to be inserted is this:
USERID,COUNT,TIMES
STEVE20,10,3.5

the old record is this:
USERID,COUNT,TIMES
STEVE20,24,1.5

The updated record will be:
USERID,COUNT,TIMES
STEVE20,34,5.0

Hope you got it.

how about label help? i mean.. get the old value and add that to a label.
example : label 1 for count, and label 2 for times

after that, on insert query just sum it

set count=value1 + '" & label1.Text & "',times=value2 + '" & label2.Text & "' where user_id="STEVE20"

and hide that label, so user can't see it :D

yes thanks artemix22, i just thought there's a simple query for that.

There is

UPDATE table SET column2 = column2 + 1

yes this is what i'm looking for.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.