Results 1 to 5 of 5
  1. #1
    johnny51981 is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2015
    Posts
    12

    Workdays Function - Need to allow for return to be Negative

    Hello!
    I have built in the Workdays function straight off of this Microsoft Link. But it seems that it will only return positive numbers. What I am looking to do is show the number of days a forecast date is out from the current date. If that forecast date is PRIOR TO the current date, I would like to see how many workdays prior that forecast date is, showing in the negative.



    Is that a possibility?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Certainly. Change that code that checks for -1 value and exits the sub.

    For a start, remove or comment out:
    Code:
        If nWeekdays = -1 Then
            Workdays = -1
            GoTo Workdays_Exit
        End If
    
    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.

  3. #3
    johnny51981 is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2015
    Posts
    12
    So, if I comment out just what you have provided above, nothing changes and all of my counts are still in the positive, even when I know there are to be negatives due to dates passed.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Did you trace the code??
    Single step through the code. You will find code in the Weekdays function that swaps the dates if the start date is less than the end date. Comment out that part of the code to get negative numbers. Hint: read the comments.

  5. #5
    johnny51981 is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2015
    Posts
    12
    That did it. Thank you both!

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

Similar Threads

  1. Can;t get Workdays function to work
    By khughes46 in forum Programming
    Replies: 5
    Last Post: 12-11-2014, 02:07 PM
  2. MaxLocksPerFile Error with Workdays Function
    By sandykj3 in forum Modules
    Replies: 2
    Last Post: 12-10-2014, 04:07 PM
  3. Function to Determine Number of Workdays Error
    By McArthurGDM in forum Modules
    Replies: 3
    Last Post: 12-08-2014, 02:51 PM
  4. Help with Workdays function (VBA) from Microsoft website
    By GregTheSquarePeg in forum Programming
    Replies: 14
    Last Post: 12-04-2013, 01:50 PM
  5. DateAdd function for workdays?
    By 10 Gauge in forum Programming
    Replies: 2
    Last Post: 04-06-2011, 09:20 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