PDA

View Full Version : Update one field with the value of the next field


Gary Williams
06-01-2005, 04:26 PM
Hi All,

I have an access database where I need to edit some records in one table (named enquiries). I have to identify those records where the field recordedited IS NULL and, for those records, enter into that recordedited field the value found in the field recordadded in the same record.

I can connect to the database OK and can write loops. What has got me is the copying of the values, a record at a time. In pseudocode, this is what I need:

UPDATE enquiries SET (the value in 'recordedited') = (the value in 'recordadded') WHERE recordedited IS NULL;

I shall keep experimenting until either I succeed or some genius posts the answer. (I suspect the genius will win)

Regards

Gary

glenngv
06-01-2005, 04:35 PM
You don't need the loop. You just execute this query.

UPDATE enquiries SET recordedited=recordadded WHERE recordedited is NULL

Gary Williams
06-01-2005, 04:47 PM
Hi Glenn,

That has to be the record for the fastest solution on this forum. I only had time to get a mug of coffee before you solution arrived :)

Many thanks, that did the job perfectly and was simpler than I expected.

Cheers Glenn

Gary

glenngv
06-02-2005, 03:20 AM
Was that really fast? I even tested it first with one of my Access databases. :cool: :thumbsup: