Results 1 to 2 of 2
  1. #1
    manos39 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Feb 2011
    Posts
    16

    Dsum expression help please

    I am using Dsum to retrieve totals of empolyees holidays or vacation, and i have this table:



    adeiestbl

    Vacationid = Autonumber
    SurnameId = Number
    DateofRequest = Date/Time
    numberofdays = Number
    Starting = Date/Time
    TypeofHolidays = Number

    then in a form havind the above table as recoursource, i am using an expression which returns the rest of the 30 days employees have the right to spend in a year:

    Code:
    =nz(IIf(30-nz(DSum("[TypeofHolidays]";"adeiestbl";"Year([Starting]) = " & Year([Starting]) & " And  [Vacationid] <= " & ([Vacationid] & " And  [SurnameId]= " & [SurnameId])))<0;
    "CHANGE THE DAYS";30-nz(DSum("[TypeofHolidays]";"adeiestbl";"Year([Starting]) = " & Year([Starting]) & " And  [Vacationid] <= " & ([Vacationid] & " And  [SurnameId ]= " & [SurnameId])))))
    The employees have the right to spend 30 days of "TypeofHolidays" in a year and this expression is working if employees spend the the whole amount of their 30 days in the specific year.

    But they have the right also to claim their days if they didnt spend them all in a year, in the next year untill almost Easter..

    Simplier if an employee has taken 20 days of "TypeofHolidays" in 2011,
    when he aplies for holidays in 2012 his whole "TypeofHolidays" amount is 10 + 30 = 40 days.

    I tried with Dsum to return the remaings of 30 days of "TypeofHolidays" for Year -1 , but its kind of tricky, and within 2012 my database will not return the right values

    I would like some help with Dsum or IIf because i have tried to calculate the value unsuccefully and .. i ve run off ideas

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I don't know if you already have, but you need a table containing TypeOfHolidays which specifies the number of days allowed per year and links to your table above. Then you can use queries to calculate how many days an employee has.

    How are the years calculated - is it from hire date or are you using calendar year, in which case there will be pro-rating? How many years can they accumulate days, is it continuous?

    One query will total how many days an employee has used - by type, for the year. Link to the Type table and get how many they are allowed. Then subtract one from the other.

    You will need to figure all this out "on paper" and then translate it into queries. DSum is not the most efficient way to go about this IMO.

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

Similar Threads

  1. Replies: 13
    Last Post: 12-05-2011, 05:10 AM
  2. Help with Sum and DSum
    By objNoob in forum Reports
    Replies: 5
    Last Post: 12-05-2011, 01:55 AM
  3. how to format the dsum value?
    By polis in forum Queries
    Replies: 7
    Last Post: 09-06-2011, 04:52 PM
  4. How do I use the DSum
    By Ironclaw in forum Access
    Replies: 1
    Last Post: 08-25-2010, 07:35 AM
  5. Help with dsum
    By bjsbrown in forum Reports
    Replies: 6
    Last Post: 02-06-2010, 09:33 AM

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