Results 1 to 13 of 13
  1. #1
    Hulkdog is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    13

    Adding calculated fields

    I am trying to create a calculated date field.

    I have a start date and an end date and would like to have the time elapsed shown as well. Then would it be possible to average all of these values in a report?

    Cheers

  2. #2
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    All that is possible.

    Let's start with the Date. Are you using the DateDiff Function?

    Where are you having a problem.

    Please post back with more details.

  3. #3
    Hulkdog is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    13
    Would you enter this as a field in the table/query/ or report. if in the report would it be a textbox?

    I have never put functions into access before.

  4. #4
    Hulkdog is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    13
    https://www.accessforums.net/access/...ery-21154.html

    This appears to help with date difference in query.

  5. #5
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Use a Query.

    Also use Access Help and search DateDiff. It will show you various examples. e.g It could return Days, Weeks, Months etc.

    Your Field for Days in the query will look something like this.

    MyResult: DateDiff("d",[YourStart],[YourEnd])

  6. #6
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Quote Originally Posted by Hulkdog View Post
    https://www.accessforums.net/access/...ery-21154.html

    This appears to help with date difference in query.

    Yes it does. It should be of some help to you.

  7. #7
    Hulkdog is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    13
    I've gotten the date difference to appear in the query by adding the function in a new field in design view. I couldn't pull this over to the report without making a new report from the query... no big deal. So I made a new report and pulled the difference function and now it is in the report...

    My Question:

    Can you put an average of the differences on the report?

  8. #8
    Hulkdog is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    13
    I have this in a field in my query:

    Diff: (DateDiff("d",[Table 1].[Field 1],[Table 1].[Field 2]))

    It produces a difference between two time fields and the result can be used on a report as well.

    I however, cannot figure out how to average all the values from this field and have it displayed on the report, for example somewhere at the bottom?

    Anyone have experience with this?

    Cheers,

  9. #9
    Michael Dean is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Iowa City, Iowa
    Posts
    8
    Hmm. I rarely design reports in Access. In coming up with a solution for you, I turned up a question of my own.

    As you explained, the name of the calculated DateDiff field you've already created in your query is "Diff"

    Now add an unbound text box to the report. Set the Control Source for this text box (without the quotation marks): "=Avg([Diff])"

    That works for me. However, it only works when it's placed in Report Header, Detail, or Report Footer sections. If I place it in Page Header or Page Footer, where you're likely to want it, the text box says "#Error" in page view. I don't know why it does that. Anyone?

  10. #10
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Michael

    Could you please post a copy of the sample Database you made.

    I would like to have a close look and see what I can find.

  11. #11
    Michael Dean is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Iowa City, Iowa
    Posts
    8
    Rainlover, I just did a quickie in a production database for that test. I'll have to make a sample db for you, maybe later today.

  12. #12
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085
    A Page Footer and Page Header is the wrong area for what you're trying to do. I would put that in a group footer or report footer.

  13. #13
    Hulkdog is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    13
    It looks and works great in the report footer. Thanks so much!

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

Similar Threads

  1. Calculated fields?
    By crcastilla in forum Queries
    Replies: 2
    Last Post: 10-31-2011, 09:30 AM
  2. Calculated Fields Help
    By Mossy in forum Queries
    Replies: 4
    Last Post: 10-10-2011, 01:13 AM
  3. Calculated fields
    By Madmax in forum Forms
    Replies: 1
    Last Post: 06-17-2011, 08:36 AM
  4. Replies: 2
    Last Post: 12-03-2010, 09:33 AM
  5. Sum of calculated fields
    By nkuebelbeck in forum Forms
    Replies: 9
    Last Post: 03-12-2010, 01:32 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