pr2-eugin
Super Moderator
- Local time
- Today, 21:00
- Joined
- Nov 30, 2011
- Messages
- 8,494
I have been using a runtime SQL query in my application, well for about a year or so. I had no problems up until today, somehow the query that normally works has ceased to work. It keeps throwing up
The SubQuery is
The other subQuery (subQry_ClaimsReport) is
I am pretty confident there is nothing wrong with the Query as it has served its purpose for a year !
I have Compacted & Repaired, Decompiled ! Still no joy. Not much info on the web too. Any ideas?
I am a bit puzzled. I have not done any design/code changes on this form (where the SQL is called) for over 5 months. I have just recently ventured into creating a new form with attachments. Changed the Data Structure of the 'Agent' table (which is used in this query) to include one attachment field. Would that make any problem. Either way, this is the Query I am usingRuntime Error 3000 - Reserved Error (-3087); there is no message for this error
Code:
SELECT
Sum(IIf([subQry_outcomeDetail].[PolicyPeriod]='Monthly' AND [subQry_outcomeDetail].[policyStatus]='Cancelled',[subQry_outcomeDetail].[Amount],0)) AS mRev,
Sum(IIf([subQry_outcomeDetail].[PolicyPeriod]='Quarterly' AND [subQry_outcomeDetail].[policyStatus]='Cancelled',[subQry_outcomeDetail].[Amount],0)) AS qRev,
Sum(IIf([subQry_outcomeDetail].[PolicyPeriod]='Annually' AND [subQry_outcomeDetail].[policyStatus]='Cancelled',[subQry_outcomeDetail].[Amount],0)) AS aRev,
[mRev]+[qRev]+[aRev] AS immRev,
([mRev]*12)+([qRev]*4)+[aRev] AS annRev
FROM (Transactions LEFT JOIN subQry_outcomeDetail ON Transactions.TRAN_ID = subQry_outcomeDetail.prospectID) INNER JOIN Agents ON Transactions.[Agent ID] = Agents.A_ID
WHERE Transactions.tranDate Between #07/11/2014# And #07/14/2014#
Code:
SELECT tbl_Clients.prospectID, tbl_PolicyDetails.InitiatingAgent, tbl_PolicyDetails.policyStatus,
tbl_PolicyDetails.policyStarted, tbl_PolicyDetails.CancelledDate, tbl_PolicyDetails.FK_clientID,
tbl_PolicyDetails.policyRefID, tbl_PolicyDetails.PolicyCode, tbl_PolicyDetails.PolicyPeriod, tbl_PolicyDetails.Amount
FROM (tbl_Clients INNER JOIN tbl_PolicyDetails ON tbl_Clients.clientID = tbl_PolicyDetails.FK_clientID)
INNER JOIN subQry_ClaimsReport ON (tbl_PolicyDetails.FK_clientID = subQry_ClaimsReport.FK_clientID) AND (tbl_PolicyDetails.policyStarted = subQry_ClaimsReport.MaxOfpolicyStarted);
Code:
SELECT tbl_PolicyDetails.FK_clientID, Max(tbl_PolicyDetails.policyStarted) AS MaxOfpolicyStarted
FROM tbl_PolicyDetails
GROUP BY tbl_PolicyDetails.FK_clientID;
I have Compacted & Repaired, Decompiled ! Still no joy. Not much info on the web too. Any ideas?