dbTalk Databases Forums  

help with calculation

comp.database.ms-access comp.database.ms-access


Discuss help with calculation in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Lancer
 
Posts: n/a

Default help with calculation - 10-27-2003 , 02:21 AM






hi , somebody help me with this little bit of calculation in access , am not
able to work out . i have 4 fields on a form , its like this , TOTAL ,
AMOUNTPAID , CREDIT , DEBIT.
now getting CREDIT by TOTAL - AMOUNTPAID is easy but incase the 2nd value
is greater the CREDIT value is shown as negative , what i want is to have
that value in debit field . seems easy but i just dont get it .
thanx

Reply With Quote
  #2  
Old   
MikeB
 
Posts: n/a

Default Re: help with calculation - 10-27-2003 , 02:24 PM






Private Sub AmountPaid_LostFocus()
If Total.Value - AmountPaid.Value = 0 Then
Debit.Value = 0
Credit.Value = 0
Else
If Total.Value - AmountPaid.Value > 0 Then
Debit.Value = Total.Value - AmountPaid.Value
Credit = 0
Else
Credit.Value = AmountPaid.Value - Total.Value
Debit.Value = 0
End If
End If
End Sub

Private Sub Form_Load()
Total = Null
AmountPaid = Null
Credit = Null
Debit = Null
End Sub

Private Sub Total_LostFocus()
If Total.Value - AmountPaid.Value = 0 Then
Debit.Value = 0
Credit.Value = 0
Else
If Total.Value - AmountPaid.Value > 0 Then
Debit.Value = Total.Value - AmountPaid.Value
Credit = 0
Else
Credit.Value = AmountPaid.Value - Total.Value
Debit.Value = 0
End If
End If
End Sub

"Lancer" <neur0lancer (AT) hotmail (DOT) com> wrote

Quote:
hi , somebody help me with this little bit of calculation in access , am not
able to work out . i have 4 fields on a form , its like this , TOTAL ,
AMOUNTPAID , CREDIT , DEBIT.
now getting CREDIT by TOTAL - AMOUNTPAID is easy but incase the 2nd value
is greater the CREDIT value is shown as negative , what i want is to have
that value in debit field . seems easy but i just dont get it .
thanx



Reply With Quote
  #3  
Old   
What-a-Tool
 
Posts: n/a

Default Re: help with calculation - 10-28-2003 , 05:09 AM



How about:

Credit : IIF(([Total]-[AmountPaid])>0,[Total]-[AmountPaid], Null)

Debit : IIF(([Total]-[AmountPaid])<0,[Total]-[AmountPaid], Null)

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)

"Lancer" <neur0lancer (AT) hotmail (DOT) com> wrote

Quote:
hi , somebody help me with this little bit of calculation in access , am
not
able to work out . i have 4 fields on a form , its like this , TOTAL ,
AMOUNTPAID , CREDIT , DEBIT.
now getting CREDIT by TOTAL - AMOUNTPAID is easy but incase the 2nd
value
is greater the CREDIT value is shown as negative , what i want is to have
that value in debit field . seems easy but i just dont get it .
thanx



Reply With Quote
  #4  
Old   
Lancer
 
Posts: n/a

Default Re: help with calculation - 10-28-2003 , 01:20 PM



thanx , both the methods work fine

"What-a-Tool" <Die!FrigginSpammersDieDie!@NoShitSherlock.Net> wrote

Quote:
How about:

Credit : IIF(([Total]-[AmountPaid])>0,[Total]-[AmountPaid], Null)

Debit : IIF(([Total]-[AmountPaid])<0,[Total]-[AmountPaid], Null)

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)

"Lancer" <neur0lancer (AT) hotmail (DOT) com> wrote in message
news:6cc5e68a.0310270021.1b8268db (AT) posting (DOT) google.com...
hi , somebody help me with this little bit of calculation in access , am
not
able to work out . i have 4 fields on a form , its like this , TOTAL ,
AMOUNTPAID , CREDIT , DEBIT.
now getting CREDIT by TOTAL - AMOUNTPAID is easy but incase the 2nd
value
is greater the CREDIT value is shown as negative , what i want is to have
that value in debit field . seems easy but i just dont get it .
thanx

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.