Set working days to zero if the end date is blank.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KasSamrari
    New Member
    • Jan 2010
    • 1

    Set working days to zero if the end date is blank.

    Hello,

    I am working on an access dB where the release date is only populated once the products have been released otherwise remain blank. I can calculate the working days if the MfgDate and FFReleaseDate are both populated but get an #error if the FFReleaseDate is blank. I would like the working days to be zero if the release date field is blank. Doing this with vba code (Attached). Please help.

    Regards,
    Kas
    Attached Files
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi. Problem is that you are defining the type of parameter FFReleaseDate as a Date type. This is not compatible with passing in a Null value.

    You will need to redefine the parameter as a Variant, and test for null explicitly

    Code:
    Public Function Workdays(...,  ByVal FFReleaseDate as Variant, ...
    
    ' Add test before other lines in main body
    If IsNull(FFReleaseDate) then
      Workdays = 0
      Exit Function
    end if
    As you are not changing the value of FFReleaseDate there is no need to pass it by reference. I have changed ByRef to ByVal above accordingly.

    -Stewart

    Comment

    Working...