S
seeker
The following sql in access
DELETE DETAIL2.ID, DETAIL2.[DET:CUSTNO], DETAIL2.[DET:INVIDX],
DETAIL2.[DET:CUSTIDX], DETAIL2.[DET:INVOICE], DETAIL2.[DETATE],
DETAIL2.[DET:JULDATE], DETAIL2.[DET:ITEMNBR1], DETAIL2.[DET:ITEMNBR2],
DETAIL2.[DET:ITEMNBR3], DETAIL2.[DET:ITEMNBR4], DETAIL2.[DET:ITEMNBR5],
DETAIL2.[DET:ITEMDESC1], DETAIL2.[DET:ITEMDESC2], DETAIL2.[DET:ITEMDESC3],
DETAIL2.[DET:ITEMDESC4], DETAIL2.[DET:ITEMDESC5], DETAIL2.[DETRICE1],
DETAIL2.[DETRICE2], DETAIL2.[DETRICE3], DETAIL2.[DETRICE4],
DETAIL2.[DETRICE5], DETAIL2.[DET:IPRICE1], DETAIL2.[DET:IPRICE2],
DETAIL2.[DET:IPRICE3], DETAIL2.[DET:IPRICE4], DETAIL2.[DET:IPRICE5],
DETAIL2.[DET:CARD1], DETAIL2.[DET:CARD2], DETAIL2.CardToSend,
DETAIL2.CardToSend1Year, DETAIL2.[DET:REMARK1], DETAIL2.[DET:REMARK2],
DETAIL2.[DET:REMARK3], DETAIL2.[DET:SUBTOT], DETAIL2.[DET:TAXABLE],
DETAIL2.[DET:TAX], DETAIL2.[DET:CARYEAR], DETAIL2.[DET:CARKEY],
DETAIL2.[DET:CARID], DETAIL2.[DET:FORSALE], DETAIL2.[DET:TOMAIL],
DETAIL2.[DET:NOTE], DETAIL2.[DETEPT], DETAIL2.[DETAYROLLDATE],
DETAIL2.[DET:EMPW1], DETAIL2.[DET:EMPW2], DETAIL2.[DET:EMPP1],
DETAIL2.[DET:EMPO1], DETAIL2.[DET:EMPO2], DETAIL2.[DET:EMPO3],
DETAIL2.[DET:EMPI1], DETAIL2.[DET:EMPI2], DETAIL2.[DET:EMPI3],
DETAIL2.[DET:EMPX1], DETAIL2.[DET:EMPX2], DETAIL2.[DET:EMPX3A],
DETAIL2.[DET:EMPX3B], DETAIL2.[DET:EMPX3C], DETAIL2.[DET:WASH1],
DETAIL2.[DET:WASH2], DETAIL2.[DET:MOTOR], DETAIL2.[DETAINTYN],
DETAIL2.[DETAINT], DETAIL2.[DET:OUT1], DETAIL2.[DET:OUT2],
DETAIL2.[DET:OUT3], DETAIL2.[DET:INT1], DETAIL2.[DET:INT2],
DETAIL2.[DET:INT3], DETAIL2.[DET:XTDESC1], DETAIL2.[DET:XTDESC2],
DETAIL2.[DET:XTDESC3], DETAIL2.[DET:XTDESC4], DETAIL2.[DET:XTDESC5],
DETAIL2.[DET:XT1], DETAIL2.[DET:XT2], DETAIL2.[DET:XT3A], DETAIL2.[DET:XT3B],
DETAIL2.[DET:XT3C], DETAIL2.[DET:XTP1], DETAIL2.[DET:XTP2],
DETAIL2.[DET:XTP3A], DETAIL2.[DET:XTP3B], DETAIL2.[DET:XTP3C],
DETAIL2.[DET:WASHP1], DETAIL2.[DET:WASHP2], DETAIL2.[DETAINTP],
DETAIL2.[DET:OUTP1], DETAIL2.[DET:OUTP2], DETAIL2.[DET:OUTP3],
DETAIL2.[DET:INTP1], DETAIL2.[DET:INTP2], DETAIL2.[DET:INTP3],
qryCountOfInvoices.[CountOfDET:INVOICE]
FROM DETAIL2 INNER JOIN qryCountOfInvoices ON DETAIL2.[DET:CUSTNO] =
qryCountOfInvoices.[DET:CUSTNO]
WHERE
(((DETAIL2.[DETATE])<=[forms]![frmarchiveinvoicesoptions]![txtarchivedate])
AND ((DETAIL2.[DET:TAXABLE]) Like
IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='wholesale',"N",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='retail',"Y",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='all','*'))))
AND
((qryCountOfInvoices.[CountOfDET:INVOICE])>=[forms]![frmarchiveinvoicesoptions]![txtnumberofinvoices]));
gives me the error that I need to specify which table I am deleteing from.
I have the count in the joined table to determine the customers with a
certain number of invoices. These invoices need to be deleted from detail2.
If i put the count in a subquery for criteria to be deleted and place
count(det:invoice) it tells me that an aggregate can not be used in a delete
query. Thanks for your help
DELETE DETAIL2.ID, DETAIL2.[DET:CUSTNO], DETAIL2.[DET:INVIDX],
DETAIL2.[DET:CUSTIDX], DETAIL2.[DET:INVOICE], DETAIL2.[DETATE],
DETAIL2.[DET:JULDATE], DETAIL2.[DET:ITEMNBR1], DETAIL2.[DET:ITEMNBR2],
DETAIL2.[DET:ITEMNBR3], DETAIL2.[DET:ITEMNBR4], DETAIL2.[DET:ITEMNBR5],
DETAIL2.[DET:ITEMDESC1], DETAIL2.[DET:ITEMDESC2], DETAIL2.[DET:ITEMDESC3],
DETAIL2.[DET:ITEMDESC4], DETAIL2.[DET:ITEMDESC5], DETAIL2.[DETRICE1],
DETAIL2.[DETRICE2], DETAIL2.[DETRICE3], DETAIL2.[DETRICE4],
DETAIL2.[DETRICE5], DETAIL2.[DET:IPRICE1], DETAIL2.[DET:IPRICE2],
DETAIL2.[DET:IPRICE3], DETAIL2.[DET:IPRICE4], DETAIL2.[DET:IPRICE5],
DETAIL2.[DET:CARD1], DETAIL2.[DET:CARD2], DETAIL2.CardToSend,
DETAIL2.CardToSend1Year, DETAIL2.[DET:REMARK1], DETAIL2.[DET:REMARK2],
DETAIL2.[DET:REMARK3], DETAIL2.[DET:SUBTOT], DETAIL2.[DET:TAXABLE],
DETAIL2.[DET:TAX], DETAIL2.[DET:CARYEAR], DETAIL2.[DET:CARKEY],
DETAIL2.[DET:CARID], DETAIL2.[DET:FORSALE], DETAIL2.[DET:TOMAIL],
DETAIL2.[DET:NOTE], DETAIL2.[DETEPT], DETAIL2.[DETAYROLLDATE],
DETAIL2.[DET:EMPW1], DETAIL2.[DET:EMPW2], DETAIL2.[DET:EMPP1],
DETAIL2.[DET:EMPO1], DETAIL2.[DET:EMPO2], DETAIL2.[DET:EMPO3],
DETAIL2.[DET:EMPI1], DETAIL2.[DET:EMPI2], DETAIL2.[DET:EMPI3],
DETAIL2.[DET:EMPX1], DETAIL2.[DET:EMPX2], DETAIL2.[DET:EMPX3A],
DETAIL2.[DET:EMPX3B], DETAIL2.[DET:EMPX3C], DETAIL2.[DET:WASH1],
DETAIL2.[DET:WASH2], DETAIL2.[DET:MOTOR], DETAIL2.[DETAINTYN],
DETAIL2.[DETAINT], DETAIL2.[DET:OUT1], DETAIL2.[DET:OUT2],
DETAIL2.[DET:OUT3], DETAIL2.[DET:INT1], DETAIL2.[DET:INT2],
DETAIL2.[DET:INT3], DETAIL2.[DET:XTDESC1], DETAIL2.[DET:XTDESC2],
DETAIL2.[DET:XTDESC3], DETAIL2.[DET:XTDESC4], DETAIL2.[DET:XTDESC5],
DETAIL2.[DET:XT1], DETAIL2.[DET:XT2], DETAIL2.[DET:XT3A], DETAIL2.[DET:XT3B],
DETAIL2.[DET:XT3C], DETAIL2.[DET:XTP1], DETAIL2.[DET:XTP2],
DETAIL2.[DET:XTP3A], DETAIL2.[DET:XTP3B], DETAIL2.[DET:XTP3C],
DETAIL2.[DET:WASHP1], DETAIL2.[DET:WASHP2], DETAIL2.[DETAINTP],
DETAIL2.[DET:OUTP1], DETAIL2.[DET:OUTP2], DETAIL2.[DET:OUTP3],
DETAIL2.[DET:INTP1], DETAIL2.[DET:INTP2], DETAIL2.[DET:INTP3],
qryCountOfInvoices.[CountOfDET:INVOICE]
FROM DETAIL2 INNER JOIN qryCountOfInvoices ON DETAIL2.[DET:CUSTNO] =
qryCountOfInvoices.[DET:CUSTNO]
WHERE
(((DETAIL2.[DETATE])<=[forms]![frmarchiveinvoicesoptions]![txtarchivedate])
AND ((DETAIL2.[DET:TAXABLE]) Like
IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='wholesale',"N",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='retail',"Y",IIf([forms]![frmarchiveinvoicesoptions]![txtacceptedarchivetype]='all','*'))))
AND
((qryCountOfInvoices.[CountOfDET:INVOICE])>=[forms]![frmarchiveinvoicesoptions]![txtnumberofinvoices]));
gives me the error that I need to specify which table I am deleteing from.
I have the count in the joined table to determine the customers with a
certain number of invoices. These invoices need to be deleted from detail2.
If i put the count in a subquery for criteria to be deleted and place
count(det:invoice) it tells me that an aggregate can not be used in a delete
query. Thanks for your help