Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update MS Access table

Status
Not open for further replies.

hugh999

MIS
Nov 29, 2001
129
IE
I found the following code for updating a table in MS Access which works fine

Code:
OleDbUpdateCommand1.CommandText = _
                 "UPDATE tblStats SET CarNames=" & _
                 "'" & TextBox1.Text & _
                 "' WHERE ID=" & IDTextBox.Text & "  ; "
How can I expand this to update other data on the same row. Example: Update the field “CarReg” from TextBox2.Text and update the filed “Speed” from TextBox2.Text

Thanks
 
The piece you're looking for is the comma separating the fields and values.

Code:
OleDbUpdateCommand1.CommandText = "UPDATE tblStats " & _
				" SET CarNames= '" & TextBox1.Text & "', " & _
					" CarReg = '" & TextBox2.Text & "', " & _
					" Speed = '" & TextBox3.Text & "'" & _
				" WHERE ID= " & IDTextBox.Text & " ;"

"If I were to wake up with my head sewn to the carpet, I wouldn't be more surprised than I am right now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top