tags:

views:

2668

answers:

5

MS Access: How to replace blank (null ) values with 0 for all records?

I guess it has to be done using SQL. I can use Find and Replace to replace 0 with blank, but not the other way around (won't "find" a blank, even if I enter [Ctrl-Spacebar] which inserts a space.

So I guess I need to do SQL where I find null values for MyField, then replace all of them with 0.

Any help is greatly appreciated.

Thanks, The Find & Replace guy.

A: 

Go to the query designer window, switch to SQL mode, and try this:

Update Table Set MyField = 0
Where MyField Is Null; 
Charles Bretana
The first answer is also correct and would have enabled me to get it, but this one has the added benefit of Access-specific instructions that made it go a little faster.THANKS to all of you for your help, and Happy New Year!
rick
+1  A: 
UPDATE table SET column=0 WHERE column IS NULL
mopoke
+2  A: 

If you're trying to do this with a query, then here is your answer:

SELECT ISNULL([field], 0) FROM [table]

If you want to replace the actual values in the table, then you'll need to do it this way:

UPDATE [table] SET [FIELD] = 0 WHERE [FIELD] IS NULL
Gabriel McAdams
A: 
UPDATE YourTable SET MyField = 0 WHERE MyField IS NULL

works in most SQL dialects. I don't use Access, but that should get you started.

Ken White
A: 

Recommmend you use MDBScript to export your entire database to .sql script file, then modify it and execute your .sql script file to re-create a replication of your MS Access database.

Further information: http://www.mdbscript.com/