Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

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

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I have found your site brilliant. What makes it good are the people that contribute to the site..."

Geography

Where in the world do Tek-Tips members come from?
MICKI0220 (IS/IT--Management)
31 Jul 12 10:48
I am having a brain lockup. I have been writing this program using alot of sql updates to make a work table. Right now I am coming into a problem with a calculation on commissions. Here is my problem. I have a commission database that salesmen recieve a commission when a payment comes in on a contract. However it is only for maybe two years of a ten year commission that they get commission. So the field CommissionRemaining, may have 20 dollars left, but the calculation on commission this period may be 50 dollars. I need to code a statement on the table that changes the commissionthis period to be only what is left. So my statement is this in pseudocode

CODE

If CommissionRemaining.value >  CommissionEarnedThisPeriod than CommissionEarnedThisPeriod.value = CommissionEarnedThisPeriod.value Else 
CommissionEarnedThisPeriod.value = CommissionRemaining.value 

I hope I have explained it correctly. I am assuming that because I am not using a query that I will need to link the table with a dlookup. My primary key is JOBID. This code would need to do this for all records in the table.

Thank you for any assistance with this.

Micki
Andrzejek (Programmer)
31 Jul 12 10:58
And I would re-write your IF statement:

If CommissionRemaining.value > CommissionEarnedThisPeriod than
CommissionEarnedThisPeriod.value = CommissionEarnedThisPeriod.value

Else
CommissionEarnedThisPeriod.value = CommissionRemaining.value
End If


To something like:

If CommissionRemaining.value <= CommissionEarnedThisPeriod than
CommissionEarnedThisPeriod.value = CommissionRemaining.value
End If

Have fun.

---- Andy

MICKI0220 (IS/IT--Management)
31 Jul 12 11:08
Phv
Can I put that whole if statement in an IIf function in an sql statement If have used the IIf statements for things like if the value is less than >0, 0.
PHV (MIS)
31 Jul 12 11:15
MICKI0220 (IS/IT--Management)
31 Jul 12 11:45
This is what I am using and instead of taking the value of it, it puts a zero in its value.

CODE

DoCmd.RunSQL "UPDATE Projects SET Projects.ResultingCommissionPeriodReg = IIf([Projects]![ResultingCommissionPeriodReg]>[Projects]![TotalComRemaining],[Projects]![TotalComRemaining],[Projects]![ResultingCommissionPeriodReg])" 

Thanks again for the input.
Helpful Member!  PHV (MIS)
31 Jul 12 12:19
Seems like Projects.ResultingCommissionPeriodReg is already set to zero before the update ...
instead of taking the value of it
The value of what ?

Hope This Helps, PH.
FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

MICKI0220 (IS/IT--Management)
31 Jul 12 12:26
it's not set to zero. I keep running the code piece by piece by commenting it out and right before this part runs, the field has 2900.00 in it. I just meant the value as in 2900.00.
PHV (MIS)
31 Jul 12 12:57
What about this ?
DoCmd.RunSQL "UPDATE Projects SET ResultingCommissionPeriodReg=TotalComRemaining WHERE ResultingCommissionPeriodReg>TotalComRemaining"

the field has 2900.00 in it
In the table ?

Hope This Helps, PH.
FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

MICKI0220 (IS/IT--Management)
31 Jul 12 13:29
I got it to work. Thank you.
PHV (MIS)
31 Jul 12 15:26
I got it to work
Please, share your working solution.
MICKI0220 (IS/IT--Management)
2 Aug 12 11:45
The problem was that one of the records I was using to verify things were working had a null value in the total commission remaining field. Once it had a value it worked like a charm.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

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:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close