Pages

Showing posts with label Update table using DAO. Show all posts
Showing posts with label Update table using DAO. Show all posts

Tuesday, December 27, 2011

Update table using DAO

If you want to make the changes in the existing table.

Here is the code-


Sub update_table_records_by_DAO()
DoCmd.SetWarnings (False)
Dim rs As Recordset
'' if you want the staff name "a" changed to ashish in the table "sales_detail" and "rep name" is the field name
Set rs = CurrentDb.OpenRecordset("SALES_DETAIL", dbOpenDynaset)
rs.MoveFirst
Do While Not rs.EOF
rs.Edit
If rs.Fields![Rep name].Value = "Ashish" Then
rs.Fields![Rep name].Value = "a"
End If
rs.Update
rs.MoveNext
Loop
rs.Close
DoCmd.SetWarnings (True)
End Sub


Download Access Database