mrong
asked on
Overflow error for MS Access 2000 Query
Hi Experts,
I have the following query in Access 2000 and gets 'overflow' error when I tried to run it.
My query was working fine untill I added->WHERE ((([ACTEXP]+[COMEXP])/[BUD AMT])>0.8)
I only want select the record if its ([ACTEXP]+[COMEXP])/[BUDAM T] >80%
Thanks in advance!
SELECT [Acctstat].[FUNDAC], [Fundacs].[DESC] AS Fundacs_DESC, [Acctstat].[OBJ], [Objcodes].[DESC] AS Objcodes_DESC, [Acctstat].[BUDAMT], Sum(IIf([req query for acctstat calculations]![OBJ]=[Accts tat]![OBJ] And [req query for acctstat calculations]![FUNDAC]=[Ac ctstat]![F UNDAC],[re q query for acctstat calculations]![EXPAMT],0)) AS ACTEXP, Sum(IIf([req query for acctstat calculations]![OBJ]=[Accts tat]![OBJ] And [req query for acctstat calculations]![FUNDAC]=[Ac ctstat]![F UNDAC],[re q query for acctstat calculations]![REQBAL],0)) AS COMEXP, [BUDAMT]-[ACTEXP] AS ACTBAL, ([BUDAMT]-[ACTEXP])-[COMEX P] AS AVAILBAL, IIf([BUDAMT]<>0,100*[ACTEX P]/[BUDAMT ],0) AS PERACT, IIf([BUDAMT]<>0,(IIf([BUDA MT]=0 And [COMEXP]=0,1,100*([ACTEXP] +[COMEXP]) /[BUDAMT]) ),0) AS PERAVAIL
FROM [req query for acctstat calculations], (Acctstat INNER JOIN Objcodes ON [Acctstat].[OBJ]=[Objcodes ].[OBJ]) INNER JOIN Fundacs ON [Acctstat].[FUNDAC]=[Funda cs].[FUNDA C]
WHERE ((([ACTEXP]+[COMEXP])/[BUD AMT])>0.8)
GROUP BY [Acctstat].[FUNDAC], [Fundacs].[DESC], [Acctstat].[OBJ], [Objcodes].[DESC], [Acctstat].[BUDAMT], [BUDAMT]-[ACTEXP], ([BUDAMT]-[ACTEXP])-[COMEX P], IIf([BUDAMT]<>0,100*[ACTEX P]/[BUDAMT ],0), IIf([BUDAMT]<>0,(IIf([BUDA MT]=0 And [COMEXP]=0,1,100*([ACTEXP] +[COMEXP]) /[BUDAMT]) ),0), [req query for acctstat calculations].[FUNDAC]
HAVING ((([req query for acctstat calculations].FUNDAC)=[Acc tstat]![FU NDAC]))
ORDER BY [Acctstat].[FUNDAC], [Acctstat].[OBJ];
I have the following query in Access 2000 and gets 'overflow' error when I tried to run it.
My query was working fine untill I added->WHERE ((([ACTEXP]+[COMEXP])/[BUD
I only want select the record if its ([ACTEXP]+[COMEXP])/[BUDAM
Thanks in advance!
SELECT [Acctstat].[FUNDAC], [Fundacs].[DESC] AS Fundacs_DESC, [Acctstat].[OBJ], [Objcodes].[DESC] AS Objcodes_DESC, [Acctstat].[BUDAMT], Sum(IIf([req query for acctstat calculations]![OBJ]=[Accts
FROM [req query for acctstat calculations], (Acctstat INNER JOIN Objcodes ON [Acctstat].[OBJ]=[Objcodes
WHERE ((([ACTEXP]+[COMEXP])/[BUD
GROUP BY [Acctstat].[FUNDAC], [Fundacs].[DESC], [Acctstat].[OBJ], [Objcodes].[DESC], [Acctstat].[BUDAMT], [BUDAMT]-[ACTEXP], ([BUDAMT]-[ACTEXP])-[COMEX
HAVING ((([req query for acctstat calculations].FUNDAC)=[Acc
ORDER BY [Acctstat].[FUNDAC], [Acctstat].[OBJ];
is [BUDAMT] value a zero in the data you are using?
jaffer
jaffer
ASKER
jaffer,
[BUDAMT] has a zero value sometimes and I think that caused the error, but how to fix it?
Thanks.
[BUDAMT] has a zero value sometimes and I think that caused the error, but how to fix it?
Thanks.
What do you want to do if [BUDAMT] has a zero value?
try to modify this example:
WHERE ([BUDAMT] <>0 and (([ACTEXP]+[COMEXP])/[BUDA
ASKER
I made the change but still get "overflow" error.
is any of data a NULL in one of these fields:
[ACTEXP] OR [COMEXP] OR [BUDAMT]
[ACTEXP] OR [COMEXP] OR [BUDAMT]
ASKER
Both [ACTEXP] and [COMEXP] can be either Null or zero. They are just calculation from other fields.
Thanks.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Actually I want use-> WHERE (Sum([ACTEXP])>0 And Sum([COMEXP])>0 And Sum([BUDAMT])>0 And ((Sum([ACTEXP])+Sum([COMEX P]))/Sum([ BUDAMT]))> 0.8)
Got error: can't have aggregate function in where clause.
Got error: can't have aggregate function in where clause.
Hi mrong
Don't put the Sum in the Where statement,
make another field in the query, call it SumACTEXP, like this:
SumACTEXP: dsum("[ACTEXP]","TableName ", where condition if any)
SumCOMEXP: dsum("[COMEXP]","TableName ", where condition if any)
SumBUDAMT: dsum("[BUDAMT]","TableName ", where condition if any)
then your Where statement should look like this:
WHERE ([SumACTEXP]>0 and [SumCOMEXP]>0 and [SumBUDAMT] >0 and (([ACTEXP]+[COMEXP])/[BUDA MT])>0.8)
Alternatively, you can put the DSUM statements in the Form where you are calling the Query from and refere to it like this:
WHERE (Forms![FormName]![SumACTE XP]>0 and Forms![FormName]![SumCOMEX P]>0 and Forms![FormName]![SumBUDAM T] >0 and (([ACTEXP]+[COMEXP])/[BUDA MT])>0.8)
jaffer
Don't put the Sum in the Where statement,
make another field in the query, call it SumACTEXP, like this:
SumACTEXP: dsum("[ACTEXP]","TableName
SumCOMEXP: dsum("[COMEXP]","TableName
SumBUDAMT: dsum("[BUDAMT]","TableName
then your Where statement should look like this:
WHERE ([SumACTEXP]>0 and [SumCOMEXP]>0 and [SumBUDAMT] >0 and (([ACTEXP]+[COMEXP])/[BUDA
Alternatively, you can put the DSUM statements in the Form where you are calling the Query from and refere to it like this:
WHERE (Forms![FormName]![SumACTE
jaffer
For example, Integer can handle -32767 to +32768, so if you try to feed it 200,000, you get an overflow error.
Byte can handle 0 to 255, so if you try to feed it 500 or -5, you get an overflow error.
You get the idea.
Hope this helps.
-Jim