Results 1 to 2 of 2
  1. #1
    pampers4u is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    1

    Unhappy DSum not linking up to EmployeeName form

    Whenever I click on an employee name, I need to have the running total Balance calculated only for the employee selected in the AnnualLeave subform of the Employee form, and not to all the other employee names as is the case now.
    The formula I used to calculate the running balance is:
    =DSum("Nz([CarriedOver], 0)+Nz([Earned], 0)-Nz([Used], 0)","[AnnualLeave]")

    The formula I tried to use to restrict the running balance to the EmployeeName on the main form is:


    =DSum("Nz([CarriedOver], 0)+Nz([Earned], 0)-Nz([Used], 0)","[AnnualLeave]","EmployeeName='George'")

    But for some reason I'm getting a "#Error" message in the Balance column of the AnnualLeave subform.

    Please help!
    Thanks, Chris

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    1. I suggest a unique ID for the PayPeriod2011 table. The autonumber datatype would serve or you could structure a unique value, like 1101, 1102, etc. Retrieve the pay period dates on forms by join tables in form RecordSource query. Is this db going to serve beyond 2011?
    SELECT AnnualLeave.*, PayPeriod2011.PayPeriodEnding
    FROM PayPeriod2011 RIGHT JOIN AnnualLeave ON PayPeriod2011.PPID = AnnualLeave.PayPeriod;

    2. I suggest not using SSN for employee unique ID. Use another unique identifier as key. Again, the autonumber could serve.

    3. The Balance and Carried Over fields in Employee are not needed. Calculated value like this should not be saved to table. It can be generated when needed. Access 2010 does have a new field datatype called Calculated. This is the only way you should have these fields set up if you really want it. If you need to show value for employee leave balance to start the database, enter dummy pay period records (pay period 0). The amount carried forward to the next pay period should be calculated.
    =DSum("Nz([Earned], 0)-Nz([Used], 0)","AnnualLeave","EmpID=" & [EmpID] & " AND PayPeriod<" & [Payperiod])
    Then calculate Balance with: =Nz([CarriedOver],0)+Nz([Earned],0)-nz([Used],0)

    4. What is the determination for UseOrLose?
    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.

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

Similar Threads

  1. Replies: 0
    Last Post: 03-04-2011, 10:28 AM
  2. Open (sub)form linking 2 criteria on current form
    By websterh in forum Programming
    Replies: 2
    Last Post: 02-07-2011, 11:56 PM
  3. DSUM with date criteria from form
    By krutoigoga in forum Reports
    Replies: 4
    Last Post: 07-28-2010, 01:32 PM
  4. Linking form fields
    By rev_ollie in forum Forms
    Replies: 15
    Last Post: 07-09-2010, 06:10 AM
  5. Linking tables on a form
    By glinch in forum Queries
    Replies: 2
    Last Post: 03-26-2010, 01:08 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