Results 1 to 9 of 9
  1. #1
    claysea is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    20

    Past Due (30, 60, or 90)


    Let me start off by saying I am self-taught on Access. Having said that, I am trying to create a field that will say if an invoice is current, 30, 60, or 90 days past the invoice date. Additionally, I have a field next to the invoice date that indicates date paid. So what I want is a formula/expression?? to look indicate if an invoice is current, 30, 60, or 90 days past the invoice date (but only when the date paid field is blank). Sorry, I hope I make sense.

  2. #2
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    There are several ways of doing this but I personally would use the following

    In a Module add the following

    Public Function pastdue(ByRef dtVal as date) As String

    Select Case DateDiff("d",dtval,Date())

    Case Is < 30
    Pastdue = "Current"
    Case 31 To 60
    Pastdue = "30 Days"
    Case 61 To 90
    Pastdue = "90 days"
    Case Else
    Pastdue = "Greater than 90 days"

    end Select

    end function

    Then call the function where ever you need to.

  3. #3
    claysea is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    20
    I don't know what a module is and the information above looks greek to me. Is there something I can add in the Control Source section of a form or report?

  4. #4
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    Yes you can but it's a lot more complicated. You simply create a module and place the VBA Code there How you create a module Depends on your version of Access. Thats the easiest then in your Form, Report you add a text box and in the control source you put in =IIF(isNull([datepaid]),pastdue(invoicedate),"")

    To put it into a control on a form or report requires the following

    =IIF(IsNull([datepaid]),IIF(datediff("d",[invoicedate],date())<30,"Current",IIF(datediff("d",[invoicedate],date()) between 31 and 60,"30 Days",IIF(datediff("d",[invoicedate],date()) between 61 and 90,"60 Days","90 Days"))),"")

    plus you have to do it every time you want that to display.

  5. #5
    dgaletar is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2013
    Location
    Washington, DC
    Posts
    85
    Quote Originally Posted by RayMilhon View Post
    Yes you can but it's a lot more complicated. You simply create a module and place the VBA Code there How you create a module Depends on your version of Access. Thats the easiest then in your Form, Report you add a text box and in the control source you put in =IIF(isNull([datepaid]),pastdue(invoicedate),"")

    To put it into a control on a form or report requires the following

    =IIF(IsNull([datepaid]),IIF(datediff("d",[invoicedate],date())<30,"Current",IIF(datediff("d",[invoicedate],date()) between 31 and 60,"30 Days",IIF(datediff("d",[invoicedate],date()) between 61 and 90,"60 Days","90 Days"))),"")

    plus you have to do it every time you want that to display.
    Hello. I am also fairly new to Access, and am completely self taught. I actually have a very similar request; to create a report that shows Vehicle numbers that have not been serviced in the last 30 to 59 days, 60 to 89 days, and over 90 days.

    I tried to use the information above but it didn't work.

    The table that I have the "Service" dates in is surprisingly called "SERVICE". Within that table I have two fields that I assume I will be working with: tb_CUA (which is the vehicle number that we have assigned to it), and Date (which is a list of dates that the vehicle was serviced).

    I created a MACRO like suggested above, and named it "30_60_90", but am a little confused as to what I should be doing next.

    I tried creating both a form and a report and put
    Thats the easiest then in your Form, Report you add a text box and in the control source you put in =IIF(isNull([datepaid]),pastdue(invoicedate),"")
    into the control field of the Text Box, but it keeps returning the value #Name?.

    Any and all suggestions would be GREATLY appreciated!

  6. #6
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    Did you add the function pastdue from my first post. If not, then access has no idea what pastdue(invoicedate) is and you will receive the error #Name. You say you created a macro my post talked about a module two different things.

  7. #7
    dgaletar is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2013
    Location
    Washington, DC
    Posts
    85
    Got it. I just figured that out (thanks to pbaldy setting me straight. I've never worked with a Module, so he told me how to do it.). So now I have the VBA that you listed above placed in a module named 30_60_90. I then created a form and added a textbox. In the "Control Source" for that text box I entered "=pastdue([«dtVal»])".

    When I view the form, the same error comes up; #Name?.

  8. #8
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    If you open the Module at the top you should see

    Option Compare Database
    Option Explicit

    Publc Function Pastdue(ByRef dtvalue as date) as string

    If not then copy what you have in the module and post it here. I'll take a look

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Heads up Ray, discussion going on in two threads:

    https://www.accessforums.net/access/...0-a-32382.html
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Reviews Past Due
    By Luke in forum Access
    Replies: 5
    Last Post: 07-19-2011, 10:51 AM
  2. Past Due Query
    By sai_rlaf in forum Queries
    Replies: 4
    Last Post: 07-06-2011, 01:53 PM
  3. Show past records for same user
    By l3111 in forum Database Design
    Replies: 3
    Last Post: 03-03-2011, 10:57 AM
  4. 12 Zeros past decimal
    By WhatnThe in forum Access
    Replies: 24
    Last Post: 01-03-2010, 09:53 PM
  5. Date Past Function
    By Laney in forum Access
    Replies: 4
    Last Post: 05-21-2008, 07:19 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