I am trying to update data in a table named tblTest using an unbound form and SQL statement. I will type the data in unbound text boxes on the form. Then I will use those data in SQL statement and finally that SQL will update the data in the table. All fields in the table are of Short Text format except the ID field which is Autonumber.
SRoll and SName are two fields on the table.
txtSRoll, txtSName, txtID are text boxes and btnUpdate is a command button on the form.
The above code gives me error. Am I missing something??
Note: Using bound forms is a crime in this project.
Code:
Private Sub btnUpdate_Click() Dim sql As String Dim A As Database Dim rCount As Integer Set A = CurrentDb() sql = "UPDATE tblTest SET SRoll = " & Me!txtSRoll & ", SName = " & Me!txtSName & " WHERE ID = " & Me!txtID & "" A.Execute sql, dbFailOnError rCount = A.RecordsAffected If rCount > 0 Then MsgBox "Contact updated" End If End Sub
txtSRoll, txtSName, txtID are text boxes and btnUpdate is a command button on the form.
The above code gives me error. Am I missing something??
Note: Using bound forms is a crime in this project.
Comment