P
Paul Fenton
In an application we run, to produce a certain report of daily
activities in a certain date range, we create a temporary table
containing all the records that meet the user's criteria. Some of
those records have start dates or end dates outside the user's
criteria, so we need to delete those records.
The temp table looks like this:
Name Task DayOfWeek Start End
Jones Paint 1 2/2/09 2/27/09
Jones Paint 2 2/2/09 2/27/09
Jones Pain 3 2/2/09 2/27/09
etc.
The table in this case would have 26 records for Jones. If the user
asks to see only the week of 2/16, he only wants 7 records on his
report, Monday thru Saturday, so we need to delete all the other
records.
Here is the code that eliminates the records from the temporary table
prior to running the report:
DoCmd.SetWarnings False
DoCmd.OpenQuery "qDeleteContractorsReportRecords"
DoCmd.SetWarnings True
And here is the query "qDeleteContractorsReportRecords"
DELETE ContractorsScheduleTemp.Start
FROM ContractorsScheduleTemp
WHERE
(((ContractorsScheduleTemp.Start)<[forms]![contractorsschedule].[txtStart]
Or
(ContractorsScheduleTemp.Start)>[forms]![contractorsschedule].[txtend]));
Where the form "contractorsschedule" has the start and end dates the
user wants, 2/16 thru 2/21 in this case.
The problem is that the records don't always delete.
If I stop the code at the "SetWarnings False" line however, and then
run the query manually from the database window, it works.
I'm stumped. What's wrong with this solution?
Paul Fenton
activities in a certain date range, we create a temporary table
containing all the records that meet the user's criteria. Some of
those records have start dates or end dates outside the user's
criteria, so we need to delete those records.
The temp table looks like this:
Name Task DayOfWeek Start End
Jones Paint 1 2/2/09 2/27/09
Jones Paint 2 2/2/09 2/27/09
Jones Pain 3 2/2/09 2/27/09
etc.
The table in this case would have 26 records for Jones. If the user
asks to see only the week of 2/16, he only wants 7 records on his
report, Monday thru Saturday, so we need to delete all the other
records.
Here is the code that eliminates the records from the temporary table
prior to running the report:
DoCmd.SetWarnings False
DoCmd.OpenQuery "qDeleteContractorsReportRecords"
DoCmd.SetWarnings True
And here is the query "qDeleteContractorsReportRecords"
DELETE ContractorsScheduleTemp.Start
FROM ContractorsScheduleTemp
WHERE
(((ContractorsScheduleTemp.Start)<[forms]![contractorsschedule].[txtStart]
Or
(ContractorsScheduleTemp.Start)>[forms]![contractorsschedule].[txtend]));
Where the form "contractorsschedule" has the start and end dates the
user wants, 2/16 thru 2/21 in this case.
The problem is that the records don't always delete.
If I stop the code at the "SetWarnings False" line however, and then
run the query manually from the database window, it works.
I'm stumped. What's wrong with this solution?
Paul Fenton