How to use code the SQL for setting two fields(columns) to NULL in Access?

I have the following code to set a field to NULL in my database which works great.

Sub Clear_Columns()
        conn.Open()
        strSQL = "UPDATE FirstShift_Checklist SET Checked_By = NULL"
         Dim cmd As New OleDbCommand(strSQL, conn)
        cmd.ExecuteNonQuery()
        conn.Close()
    End Sub

But, I need to clear out two fields, how would I do that with one SQL UPDATE statement or do I have to use two SQL UPDATE statements??

I tried this:
strSQL = "UPDATE FirstShift_Checklist SET Checked_By = NULL AND Comments = NULL"

this didn't work.

I tried this also:
strSQL = "UPDATE FirstShift_Checklist SET Checked_By = NULL AND SET Comments = NULL"

this gave me a SQL syntax error.

Any ideas??

thanks

I need to set the following to fields to NULL:
Checked_By
Comments
LVL 2
Richard KreidlSoftware DeveloperAsked:
Who is Participating?
 
AvelanCommented:
Try this:

"UPDATE FirstShift_Checklist SET Checked_By = NULL, Comments = NULL"

-Avelan
0
 
Richard KreidlSoftware DeveloperAuthor Commented:
thanks!! It worked.
0
 
shrikantssCommented:
I YOur COde
strSQL = "UPDATE FirstShift_Checklist SET Checked_By = NULL AND SET Comments = NULL"
actually the you are using keyword SET twice
or You can write it like
strSQL = "UPDATE FirstShift_Checklist SET Checked_By = NULL ,Comments = NULL"
or
strSQL  = "UPDATE FirstShift_Checklist SET Checked_By = NULL  AND Comments = NULL"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.