UPDATE Statement Example (DAO)

Microsoft Jet SQL Reference

UPDATE Statement Example

This example changes values in the ReportsTo field to 5 for all employee records that currently have ReportsTo values of 2.

Sub UpdateX()

    Dim dbs As Database

    Dim qdf As QueryDef

    ' Modify this line to include the path to Northwind

    ' on your computer.

    Set dbs = OpenDatabase("Northwind.mdb")

    

    ' Change values in the ReportsTo field to 5 for all

    ' employee records that currently have ReportsTo

    ' values of 2.

    dbs.Execute "UPDATE Employees " _

        & "SET ReportsTo = 5 " _

        & "WHERE ReportsTo = 2;"

        

    dbs.Close

End Sub