Changing value of field based on another field

D

Daniel

I am using Access 2003 and trying to change a value of a
field from 'Y' to 'N' based on whether or not the value
of another field within the same record is empty or not.
I would like the program to go through my whole database
and change this value. Any help would be greatly
appreciated.
 
D

Douglas J. Steele

UPDATE MyTable
SET MyField = 'Y'
WHERE IsNull(MyOtherField) = True

UPDATE MyTable
SET MyField = 'N'
WHERE IsNull(MyOtherField) = False

Alternatively, you could try:

UPDATE MyTable
SET MyField = IIf(IsNull(MyOtherField), 'Y', 'N')

If there's a chance that MyOtherField might have a zero-length string ("")
rather than being null, try using

LEN(MyOtherField & "") = 0

rather than

IsNull(MyOtherField)
 
Top