473,486 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Automatically deduct Commission on every 31st cycle of payment

46 New Member
I have written a small database program with MS ACCESS VBA which is meant to record Daily Savings contributions. It was quite successful but am seeing some lapses in the nearby future which I want to solve now.

In my database, on every 31st Payment cycle, a deduction is made by the system automatically but this is the code I used:

Expand|Select|Wrap|Line Numbers
  1. Commission = IIf(PaymentCycle = "31", Rate, IIf(PaymentCycle = "62", Rate, IIf(PaymentCycle = "93", Rate, IIf(PaymentCycle = "124", Rate, IIf(PaymentCycle = "155", Rate, IIf(PaymentCycle = "186", Rate, IIf(PaymentCycle = "217", Rate, IIf(PaymentCycle = "248", Rate, IIf(PaymentCycle = "279", Rate, IIf(PaymentCycle = "310", Rate, IIf(PaymentCycle = "341", Rate, IIf(PaymentCycle = "372", Rate, IIf(PaymentCycle = "402", Rate, IIf(PaymentCycle = "433", Rate, IIf(PaymentCycle = "464", Rate, IIf(PaymentCycle = "495", Rate, IIf(PaymentCycle = "526", Rate, IIf(PaymentCycle = "557", Rate, IIf(PaymentCycle = "588", Rate, IIf(PaymentCycle = "619", Rate, "0"))))))))))))))))))))

This code works with multiples of 31 but what I want to is to write a simple code whereby the system would automatically recognize the MATHEMATICAL multiples of 31 and make deductions or else when the cycle goes beyond 619 according to my code, no deduction would ever be made! I cannot keep adding so many IIf conditions.

If the Payment cycle gets to let say 3720, the system knows that it is a multiple of 31 which is (31*120) and therefore deduction is made.


Hope to find solution here
Sep 10 '13 #1
4 981
jimatqsi
1,271 Recognized Expert Top Contributor
Look at the MOD function. Your solution will look something like this:
Expand|Select|Wrap|Line Numbers
  1. if CLNG([PaymentCycle]) MOD 31 =0 then ...
CLNG is required because the MOD function requires numeric inputs. The MOD function returns the remainder of a division.

Jim
Sep 10 '13 #2
yashuaking
46 New Member
Thank you very much Jim. Am going to try this code. I can see it would work. You are my hero for the day!
Sep 10 '13 #3
yashuaking
46 New Member
It was perfect to the prefect core! It worked Perfectly to the prefect core! No need to write long line of unnecessary codes! Thank you you very much Jim!
Sep 10 '13 #4
jimatqsi
1,271 Recognized Expert Top Contributor
You're welcome :). Thanks for the feedback. It's good to know when we've helped solve a problem.

Jim
Sep 10 '13 #5

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

Similar topics

40
2595
by: findmadhav | last post by:
I need a program in C (something like a TSR) which will automatically press the function key F6, say about every 5 seconds. Can anyone provide me with an exe of such a program? Thanks in advance.
0
7126
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,...
0
7175
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...
0
7330
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...
1
4865
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...
0
4559
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...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
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...

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.