I am having difficulties creating a delete query where I have two tables, tblPayments and tblOriginalData, and want to delete records from the former, IF the record is older than 2003 AND there is a matching fk_recordnumber in the latter.
The table structures:
tblPayments
pkey
fk_recordnumber
strType
curAmount
dtmDate
tblOriginalData
pkey
fk_recordnumber
curAmount
curMed
curPHA
I need to delete all records from tblPayments where the date (dtmDate) is before Jan 1, 2003 AND there is a matching fk_recordnumber in tblOriginalData.
I created a query using the wizard which returned the following SQL:
DELETE tblPayments.*, tblPayments.dtmDate
FROM tblPayments LEFT JOIN tblOriginalData ON tblPayments.fk_RecordNumber= tblOriginalData.fk_RecordNumber
WHERE (((tblPayments.dtmDate)<#1/1/2003#));
If I VIEW the query results, it shows the correct records to be deleted, but when I RUN the query I get an error message stating "Operation must be an updatable query".
I also modified the join in the query query which resulted in the following SQL statement:
DELETE tblPayments.*, tblPayments.dtmDate
FROM tblPayments, tblOriginalData
WHERE (((tblPayments.dtmDate)<#1/1/2003# And [tblOriginalData]![fk_RecordNumber]=[tblPayments]![fk_RecordNumber]));
Still get the same error message. Is there anything obvious that I am missing?
Thanks,
Ken