Results 1 to 6 of 6
  1. #1
    Xarkath is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Millcreek WA
    Posts
    92

    Odd question about mathmatical formulas and tables

    Hello,

    Before digging into this I just want to say that I fully expect that this is not possible but some of you have already amazed me so I figure that it can't hurt to ask.

    We have clients that provide life benefits to their employees and the benefit amounts can be calculated in a number of ways. For example, the benefit could be 2 times annual salary rounded up to the nearest 1000 but capped at 75,000. Or 75% annual salary rounded up to the nearest 1000 capped at $50,000. I am guessing that I have a minimum of 20 different scenarios and that is just for life. Some clients have long and/or short term disability as well.

    What I am curious about is if I can create a table that cross references the clients to thier formula (to clarify: the formula would be stored in a field on the table) so that it can be used as a calculator by the end users. Basically thinking that on a form they could enter the client ID and the salary then push a button and get the resulting values based on the formulas stored in the table.

    I can create group specific queries or write a bunch of IIF statements but it seems like there should be a way to do this more efficiently and also in way that would allow someone more than just myself to easily add new formulas as we aquire new clients with life benefits.



    Thanks in advance for any information or insight you may have on this.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Have you worked through the scenarios to look for a pattern or some sort of grouping. In other words, do you have some written calculation/algorithm now?


    You could try something along these lines.....you know the business better than the readers..

    If years of service >x and <y and
    salary between S1 and S2 then use option 2

    If years of service <x and
    Salary between S1 and S2 then use option 4


    You could then determine "the amount" by selecting the option that applies.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I won't say no but I will say it could be difficult. Access/VBA has an Eval function. This means a string of characters: "11 * 2 / 3" can be forced to be mathematically evaluated:

    Eval("11 * 2 / 3") = 7.3333333

    So if a field stores that string, the function call could be:

    Eval([field name])

    and the content of the field would be evaluated.

    I don't really think that's what you are looking for. Will probably need VBA custom function. Store in the field some parameter that says which calc to use then call the custom function:

    MyCalcFunction([calc type], [salary])

    and branching structure in the code will lead to the correct calculation.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I agree with June7. My option 2, option4 were intended to be algorithms or functions.

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Just to add to what June7 and Orange have suggested -

    Look up how to use the Select Case ... End Select statement - it is easy to work with in VBA, and this is a perfect use for it.

    John

  6. #6
    Xarkath is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Millcreek WA
    Posts
    92
    Hi June,
    This is actually perfect. I just tried it on our worst case scenario and it works exactly as I had I hoped. And it will be much easier to train someone to enter the formulas than it would be to train them to update VBA code or such.

    Much thanks for the help, it is really appreciated.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Formulas?
    By NEHicks in forum Access
    Replies: 1
    Last Post: 06-23-2014, 10:30 AM
  2. Formulas
    By joh344 in forum Queries
    Replies: 33
    Last Post: 04-22-2014, 12:15 PM
  3. Formulas
    By dunnmel4 in forum Access
    Replies: 0
    Last Post: 03-27-2011, 04:59 PM
  4. Replies: 21
    Last Post: 12-29-2010, 01:30 PM
  5. Replies: 0
    Last Post: 03-05-2007, 08:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums