View Full Version : Update Query


SteveF
09-16-2008, 11:18 AM
Ok, dumb question time again.

I need to make an update query to change 4 fields, three of them will become 'zero' which seems pretty straightforward, but the other one needs to become what I'm replacing with one of the 'zero' figures.

To try and be a litle clearer, my columns are 'opening' 'purchases' 'credits' and 'closing'. My query will, ( theoretically :) ), set 'purchases' credits' and 'closing' to 'zero' whilst moving the figures from 'closing' to 'opening'.

As ever, all help appreciated.

Michael J Ross
09-16-2008, 11:37 AM
You'd need to run two queries i think, the first to transfer the closing to opening and the second to set the other values to zero.

SteveF
09-16-2008, 11:44 AM
So presumably the 'closing' to 'opening' first and then the 'zeros'? Any idea how I move the 'closing' to opening'? That's the bit that has me stumped.

Michael J Ross
09-16-2008, 11:53 AM
Yep thats right, update closing first. The code will be somrthing like below, replacing table1 with your table name and correct field names, copy it into the sql view of a blank query.

UPDATE Table1 SET Table1.Closing = [Table1].[Opening];

SteveF
09-16-2008, 12:25 PM
Cracked it, thanks :)

Michael J Ross
09-16-2008, 12:35 PM
Great glad to help

Edit just realised i gave you it the wrong way round, but glad you cracked it.