A simple update query with criteria

atrium

Registered User.
Local time
Tomorrow, 02:41
Joined
May 13, 2014
Messages
348
I have a table of ActionTask records and I want to select all those that have matterId = to the MatterId on a form and the Status = 'Active' and the completed field is false
The code I have written select the right records but doesn't update the required fields
Code:
UPDATE ActionTasks SET ActionTasks.Status = 'Cancelled', ActionTasks.StatusDate = Date(), ActionTasks.StatusReason = 'Not Req. DD Sched'
WHERE (((ActionTasks.Status)='Active') AND ((ActionTasks.MatterId)=[Forms]![MattersFileFrm]![MatterIdFld]) AND ((ActionTasks.Completed)=False));

Has anyone any idea why the selection criteria is working but not the update.

A thank you in anticipation
 
Are you running in VBA using RunSQL with SetWarnings turned off?

If so, leave the warnings on to see the message.
 
will do - thanks - I should have thought to try that
 
tried that and went through to say that 0 records will be updated , where in actual fact I have 14 records that should be updated
 
Are you sure the Select has identical criteria? I can't see how it could have different results for the same criteria on select and update.

Post the SQL of the Select query too.
 
Hi,

Your query is fine but make sure that [Forms]![MattersFileFrm]![MatterIdFld] has any value in it. You can check whether this reference is evaluating any value or not in Immediate window by '?[Forms]![MattersFileFrm]![MatterIdFld]'. Let us know what you see.
 
Thanks for your help guys

The variable from the other form MatterIdFld should have been MatterId

It now works well


Thanks again
 

Users who are viewing this thread

Back
Top Bottom