Private Sub cmdTest_Click()
Dim strSQL As String
Dim lngRecordsAffected As Long
strSQL = "UPDATE tblTest SET TestText = '" & _
Me.txtNewTextValue & "' WHERE TestID = " & Me.txtPKValue
CurrentProject.Connection.Execute strSQL, lngRecordsAffected, adCmdText
MsgBox lngRecordsAffected & " record(s) updated"
End Sub
Where 'tblTest' is the table to be updated, 'TestText' is the field to be
updated, 'txtNewTextValue' is the textbox containing the new value, 'TestID'
is the primary key field, and 'txtPKValue' is a textbox containing the
primary key value of the record to be updated.
--
Brendan Reynolds (MVP)
(e-mail address removed)
Drew said:
I am trying to change the value of a field with a button onClick event
within a form. The form is displaying query information and the value I
want to change is of a field in a table that I am not using within the form.
I am trying to create a Visual Basic Private Sub onClick for this. Am I
going about this the right way, or is there an easier way?