Results 1 to 4 of 4
  1. #1
    elmere is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    3

    Calculations in a form

    I am a complete Access beginner, and recently I have been trying to use Access to keep a log of expenses for staff at work (total to date for each staff, and total for each staff in the last 6 months).



    I have a sub form in data sheet view that shows expenses by a staff, linked to the main form by StaffID (auto number). I have a text box in the in the sub form that calculates the total expenses to date for each staff which works fine (using =Sum([Payment]) in the sub form and then using =[subfrmPayment].[Form]![SumOfPayment] in the main form).

    However for total expenses for each staff in the last 6 months I have tried using =DSum("Payment","tblPayment",DateDiff('d',[PaymentDate],Date())<180) in the same sub form and then using =[subfrmPayment].[Form]![6MonthPayment] in the main form. Unfortunately it calculates the total expenses for all staff for the last 6 months (or roughly 180 days), rather than for each staff.

    Given that I have little knowledge about Access, is it possible to achieve the above without using VBA code?

    Any advice for the above will be greatly appreciated!

  2. #2
    baumannp is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2011
    Posts
    2
    I'm not an expert, but I'm pretty sure you can accomplish all that without VBA. I'd probably just filter the data by date in a query then send it to a report.

  3. #3
    elmere is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    3
    Quote Originally Posted by baumannp View Post
    I'm not an expert, but I'm pretty sure you can accomplish all that without VBA. I'd probably just filter the data by date in a query then send it to a report.
    Thanks baumannp.

    I thought about perhaps a form based on a query, however it seems every time I need the latest total the query needs to be run (if I remember correctly this could be done by going to the next record in the main form and then going back to the original record). Whereas performing the calculations in the form (certainly for the total for each staff to date), any update in the sub form is seemingly automatically updated in the total to date field in the main form (=[subfrmPayment].[Form]![SumOfPayment]) without selecting the next record and going back to the original record in the main form.

    Thats why I am sticking with the form based approach (unless there is something I am not aware of).

  4. #4
    elmere is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    3
    I have attached a copy of my database.

    I am still having a problem with the '6 month payment' textbox: it calculates the total payment for all staff for the last 6 months, rather the total payment for each staff for the last 6 months.

    Hopefully it will better illustrate what I am trying to achieve!

    Any pointers or advice will be greatly appreciated.

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

Similar Threads

  1. Replies: 22
    Last Post: 03-15-2011, 07:17 AM
  2. Calculations in Form not saving to table
    By ld8732 in forum Forms
    Replies: 1
    Last Post: 01-24-2011, 07:31 PM
  3. Calculations in Query
    By jdhaldane in forum Queries
    Replies: 5
    Last Post: 12-10-2010, 05:57 AM
  4. Subform calculations
    By foureyes in forum Forms
    Replies: 4
    Last Post: 07-27-2009, 08:20 AM
  5. Time calculations
    By jimandann in forum Programming
    Replies: 2
    Last Post: 02-18-2009, 12:27 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