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

UPDATE Query

Status
Not open for further replies.

rjoshi2

Programmer
Sep 10, 2002
110
US
Can some please tell what I am doing wrong? I am trying to run a update query through a command button. Any help would be appreciated.

Thank You,
rjoshi2

SQL Query:
UPDATE tblPscITAcquisitionLog, tblObjClsDesc SET tblPscITAcquisitionLog.[Object Class] = tblObjClsDesc.[strClass], tblPscITAcquisitionLog.[Object Class Description] = tblObjClsDesc.[strDescription]
WHERE ((tblPscITAcquisitionLog.[Object Class] = tblObjClsDesc.[strClass]));

My code:
Private Sub cmdRunUpdate_Click()
Dim updateSql As String
updateSql = "UPDATE tblPscITAcquisitionLog, tblObjClsDesc" _
& "SET tblPscITAcquisitionLog.[Object Class] = tblObjClsDesc.[strClass], tblPscITAcquisitionLog.[Object Class Description] = tblObjClsDesc.[strDescription]" _
& "WHERE ((tblPscITAcquisitionLog.[Object Class] = tblObjClsDesc.[strClass])) " ';"
CurrentDb.Execute updateSql
End Sub
 
What happens?
Maybe u can try docmd.runSQL updateSQL
Be more clear in questioning please,
Errors, etc.
Thnx,
Gerard
 
Try This:

Private Sub cmdRunUpdate_Click()

Dim updateSql As String

updateSql = "UPDATE tblPscITAcquisitionLog, tblObjClsDesc"
updateSql = updateSql & " SET tblPscITAcquisitionLog.[Object Class] = tblObjClsDesc.[strClass]"
updateSql = updateSql & " , tblPscITAcquisitionLog.[Object Class Description] = tblObjClsDesc.[strDescription]"
updateSql = updateSql & " WHERE tblPscITAcquisitionLog.[Object Class] = tblObjClsDesc.[strClass];"

CurrentDb.Execute updateSql

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top