christiemhjohnson
asked on
Issue with Microsoft Access Query
I have a query that needs to multiply a dollar amount by a percentage. However, that percent is based on the Decision Package, which is another field in the query. If the Decision Package is 1, it must be multiplied by a certain percentage. If it is not 1, it needs to be multipled by a different percentage. I checked my query and it is not reading my if correctly. This is the field and how I wrote it. I tried it with and without the single quote around the Decision_Package_Code
HELP! Automatic A and 500 points
DU1RatioBreak: IIf([Decision_Package_Code ]='1',([Jo urnalAmoun t]*[DU1Per centage]), ([JournalA mount]*[DU 1Percentag e_NB]))
HELP! Automatic A and 500 points
DU1RatioBreak: IIf([Decision_Package_Code
ASKER
It doesn't give me an error, but it still doesn't read the if correctly.
Are you sure that all of your calculation fields ie [JournalAmount],[DU1Percen tage] and [DU1Percentage_NB] are all numeric, You also need to determine for sure if your [Decision_Package_Code] is text or numeric.
If All are numeric data types then your code (as is) without the quotes should work. ie
DU1RatioBreak: IIf([Decision_Package_Code ]=1,([Jour nalAmount] *[DU1Perce ntage]),([ JournalAmo unt]*[DU1P ercentage_ NB]))
Leigh
If All are numeric data types then your code (as is) without the quotes should work. ie
DU1RatioBreak: IIf([Decision_Package_Code
Leigh
ASKER
When i put Decision_Package_Code in " ", I get an error.
The other fields are fields that I have created as variables in other queries, how do I know the data type?
The other fields are fields that I have created as variables in other queries, how do I know the data type?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you cannot change or you are creating these dynamically in your query, then you can convert them for sure in this formula.
DU1RatioBreak: CDbl([JournalAmount])*CDbl(IIf([Decision_Package_Code]=1,[DU1Percentage],[DU1Percentage_NB]))
Open in new window