Calculation problem in Access

# Thread: Calculation problem in Access

1. Junior Member
Join Date
Dec 1969
Posts
5

## Calculation problem in Access

I&#039;ve built a database where I must calculate an intrest value based upon a number in a table. This number gets updated through time and eventually drops below zero. When this happens, the intrest value turns negative as well.<BR><BR>What needs to be done is that the intrest value will always be 0 when the number goes negative.<BR><BR>eg. number = 1000 then intrest = 100<BR> number = 0 then intrest = 0 (so far no problem)<BR> number = -1000 intrest = -100 (when it should be 0 here)<BR><BR>Thanks for your time, <BR>Frank.

2. Senior Member
Join Date
Dec 1969
Posts
11,334

## I think access supports IIF

if not, try it in VBS code...<BR><BR>IIf(interest &#062; -1, interest, 0)<BR><BR>Obviously make it into your own area where you need it.

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## Yes, IIF is in Access...

...because it&#039;s in VBA.<BR><BR>If you need to do this calc in VBScript, instead, write your own IIF. It&#039;s trivial:<BR><BR>&#060;%<BR>Function IIF( test, val1, val2 )<BR> If test Then IIF=val1 Else IIF=val2<BR>End Function<BR>%&#062;<BR><BR>

4. Junior Member
Join Date
Dec 1969
Posts
5

## RE: I think access supports IIF

Many thanks, Iif works perfectly

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•