Results 1 to 11 of 11
  1. #1
    undee_69 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    9

    Datediff on multiple dates in subform

    Good day accessforums people.

    I just would like to ask how to get the date difference using subforms.

    I have a main form that will count the number of days materials has been requested which it should check the latest dates on a subform. attached screenshot for your assistance.



    Click image for larger version. 

Name:	screenshot.JPG 
Views:	12 
Size:	42.0 KB 
ID:	18752is this possible?

  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
    We need some context -- where does this form and requirement fit in a typical day in our business?
    You telling us HOW you want to do something, but we don't know WHAT you are trying to accomplish.

    Data exists in tables; forms only display the data. Why can't you run a query against the table(s) involved?

  3. #3
    undee_69 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    9
    Thank you for that. what i am trying to accomplish is to track all my materials request and how many days it has passed before all the materials were completely given to requestor. I am new to access and little programming. i am using query to get my data as of the moment but i don't know how to get the latest date using query. i am attaching my db and maybe you could assist me.

    Purchase Request Tracking.zip

  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 do not use macros. Perhaps someone else can assist.

    Seems you have these tables

    Jobs
    Requestor
    Request
    Material

    It also seems you have "partial deliveries/receipt" in that not all material associated with a request is delivered at the same time.

  5. #5
    undee_69 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    9
    ah yes.. I only would like to count the days that it completed all the purchased materials.

    it will subtract the latest date of "completion date" in the subform from "requesting date" which is in the main form. but i cannot make it populate in the "completed days", also in main form.

  6. #6
    undee_69 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    9
    I al trying to do this on the beforeupdate but still won't pull out the date difference.

    Private Sub daydiff_BeforeUpdate(Cancel As Integer)

    Me.daydiff = DateDiff("ww", Forms!frmpurch!requestdate, Form!sfrmAccountNumber!max(completiondate))

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Why "ww" parameter?

    Have a textbox in the subform footer section named tbxMax with an expression: =Max([CompletionDate])

    Refer to tbxMax in textbox (or in code) on the main form:

    =DateDiff("d", requestdate, [sfrmAccountNumber].Form.tbxMax)

    Saving calculated data is usually a bad idea (calculate whenever needed). Will require code to save. I also only use VBA but the macro equivalent is SetValue action.
    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.

  8. #8
    undee_69 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    9
    I tried your suggestion @June7. I am able to get the max date if in form view but not in datasheet view. when I refer datediff to the textbox "daydiff" in the mainform, it is not showing the calculation.

    i tried adding a text box in the main form with expression =Max(sfrmAccountNumber.Form.CompletionDate) but it is giving error. when is use "=Max(sfrmAccountNumber!Form!CompletionDate)", it does not show the max date on the subform.

    Anything i am missing?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    My suggestion works for me even if subform is in datasheet view. The main form must be in Form or Continuous view. Doesn't sound like you did what I described.
    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.

  10. #10
    undee_69 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    9
    i think i may have followed your suggestion. unless i am missing something.

    Click image for larger version. 

Name:	Capture_form.JPG 
Views:	6 
Size:	38.2 KB 
ID:	18761

  11. #11
    undee_69 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    9
    i got it now. thank so much for the assistance.

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

Similar Threads

  1. Replies: 1
    Last Post: 06-09-2014, 02:04 PM
  2. Filter Subform by Combo Box Dates
    By steve042 in forum Forms
    Replies: 14
    Last Post: 06-20-2013, 07:36 AM
  3. Choose multiple dates
    By tomclavil in forum Programming
    Replies: 0
    Last Post: 04-07-2012, 11:08 PM
  4. Multiple Min/Max dates by sequential dates
    By chucku in forum Access
    Replies: 2
    Last Post: 04-05-2012, 07:43 AM
  5. Get Subform Dates
    By honey2wood in forum Forms
    Replies: 3
    Last Post: 01-13-2012, 11:03 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