Click here to Skip to main content
14,866,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have imported some data from MS access to MS excel through SQL query in VBA. Now I want to update that data(In excel) by replacing empty cells with "0". Is there any way to do that using the same query??

What I have tried:

I have tried this using vba code. it works. But is there any way to do it in the same query??
Posted
Updated 26-Jun-16 21:29pm

1 solution

Yes, it's possible:

SQL
SELECT IIF(ISNULL([yourField]), 0, [yourField]) AS SomeField
FROM [tableName];


For further information, please see:
MS Access: IsNull Function[^]
MS Access: iif Function[^]
   
Comments
Member 12605284 27-Jun-16 3:55am
   
I want to update the result pasted in ms excel sheet. I think this code is for updating ms access sheet.
Maciej Los 27-Jun-16 4:01am
   
No, you don't. When you'd use above query, you'll see zeros instead of null values in Excel.
Member 12605284 27-Jun-16 4:07am
   
Can you tell me what should I put in [your field] section?? Thanks.
Member 12605284 27-Jun-16 5:01am
   
Got it. Thanks :)
Maciej Los 27-Jun-16 6:10am
   
I'm very glad. Can you accept my answer as a solution (green button) - formally to remove question from unanswered list?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900