INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Calculation problem.

## Calculation problem.

(OP)
Morning Guys,

I have am quite new to this so please bear with me!

I have been racking my brain but i cant figure this out!

I have 5 fields: MoneyIn, Debt, TechLoan, OutstandingDebt, OutstandingTech.

Debt and Techloan do not change from their original value.

So for example the debt = 5000, techloan = 5000 and money in = 8000 (which I input).  I want to subtract the debt from the money in and then populate Outstanding debt with 0 then carry over the remaining debt to subtract from Techloan and populate OutstandingTech with 3000.

So what i am trying to do is if the money in clears debt 1 carry over to debt 2 and clear as much of that as possible.

I have been attempting this for days now and i am not getting anywhere.  Could some suggest a way i could do this?  Or some guidence where to start!

Any help will be fantastic!

Cheers

Mike

### RE: Calculation problem.

Need a little more info.... Are you trying to do this in an Access table, in a form or both?

Accourding to the above...

debt = 5000
techloan = 5000
moneyIn = 8000
OutstandingTech = moneyIn - debt
OutstandingDebt = 0

Also please clarify... "So what i am trying to do is if the money in clears debt 1 carry over to debt 2 and clear as much of that as possible."

Simi

### RE: Calculation problem.

(OP)
Afternoon

I am trying to do this on a form which is bound to a query/table.

I want to type in the debt, techloand and money in.  Click a command button and the calculation occurs.

So in the above example I type 8000 in the MoneyIn field, the techloan and the debt I have previously updated.  I click the command button this then performs the following:

Debt (5000) - MoneyIn(8000) = -3000 because the amount in is greater than debt then the 3000 is carried over to the techloan.  But because the amount in was greater than the debt, the debt is now 0 so this needs to then update the OutstandingDebt field.

TechLoan (5000) - Remainder (3000) = OutstandingTech (2000)

So the fields can never be negative, if the money in is greater than the debt then the remainder of debt - moneyin is used in techloan - money in.

Is this enough info?  Thanks for any help you can give me.

Cheers

Mike

### RE: Calculation problem.

Well it sounds like you have pretty much all you need, except if you are doing this to a bound to a query/table
then I guess you have a table of values you need to apply this to?

Or are you just wanting to plug in random ammounts and hit a button to get a total? (Unbound)

Either way it will similar.

Setup your fields on the form.

Create a button. Right click the button and choose Build Event. Then choose Build Code.

Then just build the build your code.

if Debt - MoneyIn > 0 then
techloan=Debt - MoneyIn
Else
OutstandingDebt = Debt - MoneyIn
endif

This is just psudo code but there are plent of examples on the web to help you out.

Simi

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!