Not Updating

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)
 
T

TonyT

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
 
T

Tony Toews [MVP]

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Select From 1
OR or AND 2
SQL Not Updating 2
Function or Variable Expected 6
Are Nulls Covered? 2
SQL Not Updating 5
SQL UPDATE Problem 1
UPDATE NULL RECORD 4

Top