ms access vba code for update records through form

In the cmdUpdate button’s on click event, you need to place a procedure that will generate a sql command, then execute it.

Private Sub cmdUpdate_Click()

'Create a string variable to hold your sql command string
Dim strSQL As String

'Fill the variable with your sql command, plucking values out of your 
'form as shown using the Me. operator.  When using text values in your 
'string, wrap them with the Chr(34)'s, which will insert quotation marks in 
'your sql string when it's resolved.
strSQL = "UPDATE F SET F.F5 = " & Chr(34) & yourtextvaluehere & Chr(34) & _
            " WHERE F1=" & Me.txtF1 & _
            " AND F2=" & Me.txtF2 & _
            " AND F3=" & Me.txtF3 & _
            " AND F4=" & Chr(34) & Me.txtF4 & Chr(34)

'Execute the sql statement you've built against the database
CurrentDb.Execute strSQL, dbSeeChanges + dbFailOnError

End Sub

Leave a Comment