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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Update Recordset Problem

Status
Not open for further replies.

Jeremiah31

Programmer
Nov 7, 2006
31
0
0
US
I have a form called frmRTVEditSkuDescription with three unbound controls called
cboSkuSearch
txtSku
txtdescription

I’m using an SQL statement to populate txtSku and txtdescription based on criteria selected in the cboSkuSearch control. Search works fine. The problem is if I change the value in txtdescription, the update statement (below) won’t reflect the change value. Can someone please help me?

Private Sub Command26_Click()
On Error GoTo Err_Command26_Click
Dim strSQL As String
Dim db As Database
Dim rs As Recordset

Set db = CurrentDb

strSQL = "UPDATE tblSku SET txtSku = '" & Replace(Me.txtSKU, "'", "''") & "'" _
& ", txtdescription = '" & Replace(Me.txtDescription, "'", "''") & "'" _
& " WHERE 'cboskuSearch' = '" & Me.txtSKU & "'"
CurrentDb.Execute strSQL, dbFailOnError
MsgBox strSQL

MsgBox "Changes made to Sku " & UCase(Me!cboSkuSearch) & " have been saved."

Exit_Command26_Click:
Exit Sub

Err_Command26_Click:
MsgBox Err.Description
Resume Exit_Command26_Click
End Sub
 
From what code you have posted, you are not looking at txtdescription, other than to update it. So, if you change it to "yankee doodle dandy", Access doesn't care.

If you want the query or recordset to be updated after you change txtdescription, then you'll need to put another query in the txtdescription_AfterUpdate() event.

--

"If to err is human, then I must be some kind of human!" -Me
 
Ok, I understand. What type of query should I use in the After_update event?
 
I would think you would just need the same query as you already have setup behind your button, but just include txtdescription in the criteria.

--

"If to err is human, then I must be some kind of human!" -Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top