I am attempting to archive and delete records from a timelog table using selected start [Startdate] and end date [EndDate] paramaters which are fields contained in a separate [StartEndDate] table.
I have created both an archive query and a delete query.
The Archive query works fine but when I execute the delete query I get a message: "Could not delete from specified tables"
The archive and delete vba code is as follows:
' Archive Data
'stDocName = "Archivehours"
'DoCmd.OpenQuery stDocName, acNormal, acEdit
'*******************
The SQL is as follows:
INSERT INTO ArchvedTimeLog
SELECT tblTimeLog.*
FROM tblTimeLog, StartEndDates
WHERE (((tblTimeLog.LogDate)>=[StartEndDates].[StartDate]
And (tblTimeLog.LogDate)<=[StartEndDates].[EndDate]));
'*******************
The archive action works fine.
'*******************
' Purge Active File
stDocName = "DeleteArchived_Hours"
DoCmd.OpenQuery stDocName, acNormal, acEdit
'*******************
The SQL is as follows:
DELETE DISTINCTROW tblTimeLog.*, tblTimeLog.LogDate
FROM tblTimeLog, StartEndDates
WHERE (((tblTimeLog.LogDate)>=[StartDate] And (tblTimeLog.LogDate)<=[EndDate]));
'*******************
The Table VIEW of this query looks perfect. However, upon execution, I get the message: "Could not delete from specified tables"
Any help would be greatly appreciated.
MBA
I have created both an archive query and a delete query.
The Archive query works fine but when I execute the delete query I get a message: "Could not delete from specified tables"
The archive and delete vba code is as follows:
' Archive Data
'stDocName = "Archivehours"
'DoCmd.OpenQuery stDocName, acNormal, acEdit
'*******************
The SQL is as follows:
INSERT INTO ArchvedTimeLog
SELECT tblTimeLog.*
FROM tblTimeLog, StartEndDates
WHERE (((tblTimeLog.LogDate)>=[StartEndDates].[StartDate]
And (tblTimeLog.LogDate)<=[StartEndDates].[EndDate]));
'*******************
The archive action works fine.
'*******************
' Purge Active File
stDocName = "DeleteArchived_Hours"
DoCmd.OpenQuery stDocName, acNormal, acEdit
'*******************
The SQL is as follows:
DELETE DISTINCTROW tblTimeLog.*, tblTimeLog.LogDate
FROM tblTimeLog, StartEndDates
WHERE (((tblTimeLog.LogDate)>=[StartDate] And (tblTimeLog.LogDate)<=[EndDate]));
'*******************
The Table VIEW of this query looks perfect. However, upon execution, I get the message: "Could not delete from specified tables"
Any help would be greatly appreciated.
MBA