Update a table with QueryDef : Query « Access « VBA / Excel / Access / Word






Update a table with QueryDef

 

Sub exaCreateAction()
    Dim db As Database
    Dim qdf As QueryDef
    Dim strSQL As String
    
    Set db = CurrentDb
    
    strSQL = "UPDATE BOOKS SET Price = Price*1.1 WHERE Price > 20"
    
    Set qdf = db.CreateQueryDef("PriceInc", strSQL)
    
    qdf.Execute
End Sub

 








Related examples in the same category

1.Creating a Pass-Through Query with ADOX
2.Executing a Pass-Through Query Saved in Access
3.Making Bulk Changes
4.Using a Stored Procedure to Make Bulk Changes to Data in a SQL Server Database
5.Creating a Query Using Code
6.Create Query by using the Database.CreateQueryDef
7.User Defined Property
8.Get the created query name
9.Delete a query
10.Pass parameter to a query
11.Using CreateParameter to delete a company record
12.Execuate query