Not Updating

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

This statement is not updating. Can you not update a criteria field?
Could that be it?
Thanks
DS

Dim RVDSQL As String
RVDSQL = "UPDATE tblVoidDetails SET tblVoidDetails.CDVoidReason =
Forms!frmFXVoidItemReason!TxtReasonID " & _
"WHERE tblVoidDetails.CDCheckID = Forms!frmFXVoidItem!TxtSalesID " & _
"AND tblVoidDetails.CDVoidReason = 0;"
DoCmd.RunSQL (RVDSQL)
 
DS said:
This statement is not updating. Can you not update a criteria field?
Could that be it?
Thanks
DS

Dim RVDSQL As String
RVDSQL = "UPDATE tblVoidDetails SET tblVoidDetails.CDVoidReason =
Forms!frmFXVoidItemReason!TxtReasonID " & _
"WHERE tblVoidDetails.CDCheckID = Forms!frmFXVoidItem!TxtSalesID " & _
"AND tblVoidDetails.CDVoidReason = 0;"
DoCmd.RunSQL (RVDSQL)

Try;

Dim RVDSQL As String
RVDSQL = "UPDATE tblVoidDetails SET CDVoidReason = " &
Me.TxtReasonID & "" & _
"WHERE CDCheckID = " & Me.TxtSalesID & "" & _
"AND CDVoidReason = 0"
DoCmd.RunSQL RVDSQL

mind for wordwrap - I left as you had it but edited
This assumes you are executing this code from within frmFXVoidItem
You are better off using the db.execute method rather than docmd.RunSQL
 
DS said:
Dim RVDSQL As String
RVDSQL = "UPDATE tblVoidDetails SET tblVoidDetails.CDVoidReason =
Forms!frmFXVoidItemReason!TxtReasonID " & _
"WHERE tblVoidDetails.CDCheckID = Forms!frmFXVoidItem!TxtSalesID " & _
"AND tblVoidDetails.CDVoidReason = 0;"

TonyT gave you the answer to this problem. (Fine first name and
initial there.)
DoCmd.RunSQL (RVDSQL)

I prefer, if DAO, to use Currentdb.Execute strSQL,dbfailonerror
command instead of docmd.runsql. For ADO use
CurrentProject.Connection.Execute strCommand, lngRecordsAffected,
adCmdText This will give you any warning or error messages.

Also performance can be significantly different between the two
methods. One posting stated currentdb.execute took two seconds while
docmd.runsql took eight seconds. As always YMMV.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Back
Top