473,804 Members | 3,138 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pyramid commission

n8kindt
221 New Member
hey guys,

i'm using access 2007. i'm not happy with my solution to the following problem so i'm hoping one of you guys has a better idea. my solution would require use of multiple valued fields and i know union queries and multivalued fields don't get along with each other very well. so.....


this is the typical data i'm working with:

Person A
Person B (a recruit of Person A)
Person C (a recruit of Person A)
Person D (a recruit of Person C)
Person E (a recruit of Person D)
(Person A,B,C,D,&E are all recordsets in a table)

this is basically your typical pyramid scheme. let's say PersonA recruits PersonB and PersonC. PersonA receives commission based on what PersonB & PersonC sells and a lower percentage commission of what their recruit(s) sells.

now, if a person recruits 10 ppl, they become a manager. i have created a table with fields for "recruited by" and "manager" for each person. let's assume PersonA is a manager. this works fine under this current scenario. Person D's "recruited by" field would read PersonC and the "manager" field would read PersonA. now here's my main problem. let's now assume that PersonC has just recruited 10 people and is now a manager. under this scenario, PersonD's field for "recruited by" would read PersonC and their "manager" field also will read PersonC. now there is no data to link PersonD and PersonA together even though PersonA still receives commission on PersonD's sales.

see where my problem is? i could create another field and place PersonA in that field but if PersonE were to become a manager, i'd have to create a new field AGAIN. this would occur everytime one of these person's recruits became a manager.

the only thing i can think of is to make the manager field a multivalued field so i can store more than one manager. my thinking is there has to have been someone else who has had to deal with this before (there are plenty of pyramid schemes out there). could someone give me any ideas for a simple and efficient way of tracking recruits, managers, and the base manager?

i would appreciate a quick reply b/c time is a factor in completing this system. we used to use excel to crunch this data but we had to fire the person who did this. we need to have this system going in about a week's time.
Mar 17 '08 #1
29 4207
FishVal
2,653 Recognized Expert Specialist
Hi, there.

This is a classical case to use recursive code.
You need to write a VBA function scanning down the tree (let use this commonly accepted (in programming at least) word instead of "pyramid") from a predefined node (person ID in your case).

The logic is described below in pseudocode.
Expand|Select|Wrap|Line Numbers
  1. 'the function called from query
  2. 'it has dblCommisions variable which will be passed by reference
  3. ' to recursive procedure to a accumulate commissions sum 
  4. Function GetCommisions(ByVal varPersonID As Variant) As Double
  5.  
  6.     Dim dblCommisions as Double
  7.  
  8.     dblCommisions=0
  9.     'run recursive procedure with initial values
  10.     ScanBranch(varRecruitID, 0, dblCommisions)
  11.     GetCommisions=dblCommisions
  12.  
  13. End Function
  14.  
  15. 'recursive (selfcalling) procedure
  16. ' iterating through the 1st level recruits,
  17. ' calling itself to do the same for each recruit found
  18. Sub ScanBranch(ByVal varPersonID As Variant, _
  19.                                    ByVal intNodesFromStart As Integer
  20.                                    ByRef dblIntermediateSum as Double)
  21.  
  22.     Dim varRecruitID as Variant
  23.  
  24.     'increment distance from start used in commission calculation
  25.     intNodesFromStart = intNodesFromStart+1
  26.  
  27.     Do
  28.         'get the next from 1st level recruits
  29.         varRecruitID=GetNextRecruit(varPersonID)
  30.         If <no more recruits> Then Exit Function
  31.         'add commissions depending on distance from start 
  32.         dblIntermediateSum=dblIntermediateSum + _
  33.              CalculateCommision(intNodesFromStart)
  34.         'do the same for this 1st level recruit to move down the branch
  35.         ScanBranch(varRecruitID, intNodesFromStart, dblIntermediateSum)
  36.     While True
  37.  
  38. End Sub
  39.  
Regards,
Fish
Mar 17 '08 #2
n8kindt
221 New Member
that's exactly what i was looking for!! you just made my day. thank you so much!
Mar 17 '08 #3
FishVal
2,653 Recognized Expert Specialist
that's exactly what i was looking for!! you just made my day. thank you so much!
You are welcome.
Good luck.
Mar 17 '08 #4
n8kindt
221 New Member
ok, i still need some help on this one. after looking it over, i realize this is only going to calculate the commission. in addition to this, i need a breakdown of the commissions being distributed in a report form. so, how do i display the entire tree on one report and have the commission earned displayed next to each person's name? keep in mind that i would need to have total all these figures using a sum() function.
Mar 17 '08 #5
ADezii
8,834 Recognized Expert Expert
hey guys,

i'm using access 2007. i'm not happy with my solution to the following problem so i'm hoping one of you guys has a better idea. my solution would require use of multiple valued fields and i know union queries and multivalued fields don't get along with each other very well. so.....


this is the typical data i'm working with:

Person A
Person B (a recruit of Person A)
Person C (a recruit of Person A)
Person D (a recruit of Person C)
Person E (a recruit of Person D)
(Person A,B,C,D,&E are all recordsets in a table)

this is basically your typical pyramid scheme. let's say PersonA recruits PersonB and PersonC. PersonA receives commission based on what PersonB & PersonC sells and a lower percentage commission of what their recruit(s) sells.

now, if a person recruits 10 ppl, they become a manager. i have created a table with fields for "recruited by" and "manager" for each person. let's assume PersonA is a manager. this works fine under this current scenario. Person D's "recruited by" field would read PersonC and the "manager" field would read PersonA. now here's my main problem. let's now assume that PersonC has just recruited 10 people and is now a manager. under this scenario, PersonD's field for "recruited by" would read PersonC and their "manager" field also will read PersonC. now there is no data to link PersonD and PersonA together even though PersonA still receives commission on PersonD's sales.

see where my problem is? i could create another field and place PersonA in that field but if PersonE were to become a manager, i'd have to create a new field AGAIN. this would occur everytime one of these person's recruits became a manager.

the only thing i can think of is to make the manager field a multivalued field so i can store more than one manager. my thinking is there has to have been someone else who has had to deal with this before (there are plenty of pyramid schemes out there). could someone give me any ideas for a simple and efficient way of tracking recruits, managers, and the base manager?

i would appreciate a quick reply b/c time is a factor in completing this system. we used to use excel to crunch this data but we had to fire the person who did this. we need to have this system going in about a week's time.
Just as a side note, I think that an excellent way to graphically display this hierarchical structure is to embed a Microsoft Treeview Control in a Form. Values would have to be programmed manually and the coding is a little complicated, but the end results would be worth it.
Mar 18 '08 #6
n8kindt
221 New Member
Just as a side note, I think that an excellent way to graphically display this hierarchical structure is to embed a Microsoft Treeview Control in a Form. Values would have to be programmed manually and the coding is a little complicated, but the end results would be worth it.
sounds good to me. where do i start? from what i can understand from the way you worded it, it sounds like the Microsoft Treeview Control is something i can download and then modify? i appreciate your help thus far

so far, what i have done to graphically display is using two queries and it feels very primitive lol. simply put, the first query uses the second query as a subdatasheet linked by master/child id's. this works fine except i've noticed that there is a limit on how deep this works. for me it has worked down 6 recruits and then it stops. so it's not very useful other than a quick look at seeing who recruited who.
Mar 18 '08 #7
n8kindt
221 New Member
Just as a side note, I think that an excellent way to graphically display this hierarchical structure is to embed a Microsoft Treeview Control in a Form. Values would have to be programmed manually and the coding is a little complicated, but the end results would be worth it.
is THIS what you're talking about? an activex control?

if so, and i'm showing my true newbie colors here, can i calculate my commissions through this process and use a append/update/maketable query to make the data available in a table in access?
Mar 18 '08 #8
ADezii
8,834 Recognized Expert Expert
sounds good to me. where do i start? from what i can understand from the way you worded it, it sounds like the Microsoft Treeview Control is something i can download and then modify? i appreciate your help thus far

so far, what i have done to graphically display is using two queries and it feels very primitive lol. simply put, the first query uses the second query as a subdatasheet linked by master/child id's. this works fine except i've noticed that there is a limit on how deep this works. for me it has worked down 6 recruits and then it stops. so it's not very useful other than a quick look at seeing who recruited who.
First of all, let's see if this ActiveX Control exists on your PC. In any Form Design View:
  1. Click Insert ==> ActiveX Control.
  2. Scroll down to see if the Microsoft TreeView Control is visible.
  3. Let me know how you make out.
Mar 18 '08 #9
n8kindt
221 New Member
First of all, let's see if this ActiveX Control exists on your PC. In any Form Design View:
  1. Click Insert ==> ActiveX Control.
  2. Scroll down to see if the Microsoft TreeView Control is visible.
  3. Let me know how you make out.
yes it worked! now what? :-)
Mar 18 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

7
4332
by: Jurek | last post by:
I have 10+ experience in C/C++ - mostly automation and graphics. I have never written any business apps though. Recently I've been asked to write a simple report that would calculate sales commission. The report needs to be generated from within a C/C++ app. I don't want to mess it up so I thought maybe someone from this group could give me some advice or point to me to a place that'll provide some background on the issue. Here is a...
0
1462
by: lindagoldstein100 | last post by:
Questions on Affiliate Marketing - Linkshare / Commission Junction etc ? I have heard of LinkShare, Commission junction etc ? Are these any any good ? Any one have experience with them ? Good ? Bad ? Are they worth the money ? Is it a month to month or yearly contract
8
2574
by: virtualadepts | last post by:
I spent quite a bit of work trying to get this to format on google groups, so let me know if it needs explination. Basicly the tree sorts randomly, and can start from any number on the pyramid. It has a 50/50 chance of moving down either tree. If it continues to the next number down the tree it advances. Otherwise it reatreats back up the tree on the adjacanet path. When it reaches 0 or 1, it can switch back over, and start moving in...
4
4447
by: i m gr8 | last post by:
Hello, I need to make a pyramid 20 lines long showing Xs like this: X XX XXX XXXX and so on . I have made this code so far:
6
1486
by: Marie4458 | last post by:
I gave it a try but when I debuged the form the commission rate is always $0.00. Any help is appreciated. Thanks. Private Sub xCalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xCalcButton.Click ' declare variables Const commissionRate As Decimal = 0.1D Dim sales As Decimal Dim totalCommission As Decimal
5
2297
by: jatrojoomla | last post by:
Hi! Is there any one with knowledge of CJ API development I am getting error like: http://fb.aafter.com/cj/testb/support.php during Commission Junction SOAP access Commission Junction: http://cj.com/ http://webservices.cj.com/
16
1964
by: atlbearcat | last post by:
Hell all. I have a database that tracks Commissions for recruiters (Access 2003/2003). I need to come up with a commission report on a monthly basis, which is not a problem. Where I'm having the logic problem is.... Sub-Contractor XYZ works on Project 123. He works at site ABC from 10/1/07 - 10/1/07. He works at site DEF from 10/3/07 - 10/3/07. He works at site GHI from 10/6/07 - 10/6/07. He works at site JKL from 10/9/07 - 10/9/07....
0
2124
by: spima05 | last post by:
<html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 1</title> </head>
12
4932
by: spima05 | last post by:
Hello I am developing a database to calculate commissions on a sale for each rep involved in the same and their uplines. Below is the database structure and the commissions schedule. I am having trouble designing a way to store the commission rates and calculate the commission amounts. Below is a list of the business rules for calculating the commisssions.
0
10578
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5522
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.