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

Posted on 2009-04-24
Last Modified: 2012-05-06
I have the following code to set a field to NULL in my database which works great.

Sub Clear_Columns()
        strSQL = "UPDATE FirstShift_Checklist SET Checked_By = NULL"
         Dim cmd As New OleDbCommand(strSQL, conn)
    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??


I need to set the following to fields to NULL:
Question by:rkckjk
    LVL 4

    Accepted Solution

    Try this:

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

    LVL 2

    Author Closing Comment

    thanks!! It worked.
    LVL 4

    Expert Comment

    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"
    strSQL  = "UPDATE FirstShift_Checklist SET Checked_By = NULL  AND Comments = NULL"

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now