B
Bill Fischer via AccessMonster.com
In a nutshell here is what I'm trying to do:
I run an append query to update a table with current month's totals, works
great and also updates the prior month until the 4th day of current month. I
need a delete query to remove the updated record for the current month and
prior month.
I have a been working off of the date field stamp in the table that is in
place when the append query runs with a Dmin expression. Also works great,
until prior month is updated after the 1st of the current month and there is
two records to be removed.
DELETE DISTINCTROW tblMtdYtdAllRolling.MtdYtdID, tblMtdYtdAllRolling.*
FROM tblMtdYtdAllRolling INNER JOIN qselDupltblMtdYtdAllRolling ON
tblMtdYtdAllRolling.MtdYtdID = qselDupltblMtdYtdAllRolling.MtdYtdID
WHERE (((tblMtdYtdAllRolling.MtdYtdID)=DMin("MtdYtdID","tblMtdYtdAllRolling",
" IIf(Date()>(DateSerial(Year(Date()),Month(Date()),4)), ([DateEntered]
(Date())-1,1))))
")));
As you see from the INNER JOIN the qselDupltblMtdYtdAllRolling checks for
duplicate values so just one record will not be removed if query is ran
independent (shouldn't happen but good to build in a catch net I thought).
Field Data Type Data example 1
Data example 2
AYear number 2006
2006
AMonth number 2
3
SumofInvoice currrency $40,620.75
$22,000.00
MtdYtdID PK autonumber 104
105
DateEntered Date/Time 3/1/2006 2:14:51 PM
3/1/2006 2:14:51 PM
I also have two fields in the table with year and month that will not change
on updating the table. I have been trying to tie in the month field into the
where statement to, if needed, beyond the date/time field for 2 reasons 1.
being as above stated, prior month maybe updated with current month datestamp.
2. when appended both prior and current month will have the same date stamp.
With those conditions my DMin expression will always obviously select only
the one oldest record.
I have trying to AMonth field to equal the SerialDate Month Criteria but of
course the reason I'm posting I have been unsucessful. Is there another way
to do this? Hopefully I am clear on the intentions of this process.
Also thougth of using the PK autonumber but this is a replicated database.
Very much appreciate any help (A day and a half of trying and kicking myself)
Bill Fischer
I run an append query to update a table with current month's totals, works
great and also updates the prior month until the 4th day of current month. I
need a delete query to remove the updated record for the current month and
prior month.
I have a been working off of the date field stamp in the table that is in
place when the append query runs with a Dmin expression. Also works great,
until prior month is updated after the 1st of the current month and there is
two records to be removed.
DELETE DISTINCTROW tblMtdYtdAllRolling.MtdYtdID, tblMtdYtdAllRolling.*
FROM tblMtdYtdAllRolling INNER JOIN qselDupltblMtdYtdAllRolling ON
tblMtdYtdAllRolling.MtdYtdID = qselDupltblMtdYtdAllRolling.MtdYtdID
WHERE (((tblMtdYtdAllRolling.MtdYtdID)=DMin("MtdYtdID","tblMtdYtdAllRolling",
" IIf(Date()>(DateSerial(Year(Date()),Month(Date()),4)), ([DateEntered]
(Date()),Month(Date()),1)) Or ([DateEntered]>=DateSerial(Year(Date()),Month=DateSerial(Year(Date()),Month(Date()),1)), (([DateEntered]>=DateSerial(Year
(Date())-1,1))))
")));
As you see from the INNER JOIN the qselDupltblMtdYtdAllRolling checks for
duplicate values so just one record will not be removed if query is ran
independent (shouldn't happen but good to build in a catch net I thought).
Field Data Type Data example 1
Data example 2
AYear number 2006
2006
AMonth number 2
3
SumofInvoice currrency $40,620.75
$22,000.00
MtdYtdID PK autonumber 104
105
DateEntered Date/Time 3/1/2006 2:14:51 PM
3/1/2006 2:14:51 PM
I also have two fields in the table with year and month that will not change
on updating the table. I have been trying to tie in the month field into the
where statement to, if needed, beyond the date/time field for 2 reasons 1.
being as above stated, prior month maybe updated with current month datestamp.
2. when appended both prior and current month will have the same date stamp.
With those conditions my DMin expression will always obviously select only
the one oldest record.
I have trying to AMonth field to equal the SerialDate Month Criteria but of
course the reason I'm posting I have been unsucessful. Is there another way
to do this? Hopefully I am clear on the intentions of this process.
Also thougth of using the PK autonumber but this is a replicated database.
Very much appreciate any help (A day and a half of trying and kicking myself)
Bill Fischer