Q:

Access - Use date if available, else use today's date

So this is driving me crazy and it should be super easy to do. I don't know why I can't get it working. :( At present my functions are calculating the difference between a start date and today's date, and it's working great, but now I need to implement an optional end date. So if there is an EmpEndDate available, it should be used, otherwise today's date should be used.
Here's one of my functions:
Public Function RetentionMonths(ByVal EmpStartDate As Date) As Integer

    Dim RetentionStartdate As Date
    Dim FollowingMonth As Date

        RetentionStartdate = DateAdd("ww", 14, DateAdd("d", vbSaturday - Weekday(EmpStartDate), EmpStartDate))
        FollowingMonth = DateSerial(Year(RetentionStartdate), Month(RetentionStartdate) + 1, 1)
        RetentionMonths = Months(FollowingMonth, Date)

End Function

Edit: The Months() function
Public Function Months( _
  ByVal datDate1 As Date, _
  ByVal datDate2 As Date, _
  Optional ByVal booLinear As Boolean) _
  As Integer

  Dim intDiff   As Integer
  Dim intSign   As Integer
  Dim intMonths As Integer

  intMonths = DateDiff("m", datDate1, datDate2)

  If DateDiff("d", datDate1, datDate2) > 0 Then
    intSign = Sgn(DateDiff("d", DateAdd("m", intMonths, datDate1), datDate2))
    intDiff = Abs(intSign < 0)
  Else
    intSign = Sgn(DateDiff("d", DateAdd("m", -intMonths, datDate2), datDate1))
    If intSign <> 0 Then
      intDiff = Abs(booLinear)
    End If
    intDiff = intDiff - Abs(intSign < 0)
  End If

  Months = intMonths - intDiff

End Function

And one way I've tried to tackle the issue:
Public Function RetentionMonths(ByVal EmpStartDate As Date, _
    Optional ByVal EmpEndDate As Date) _
    As Integer

    Dim RetentionStartdate As Date
    Dim FollowingMonth As Date

        RetentionStartdate = DateAdd("ww", 14, DateAdd("d", vbSaturday - Weekday(EmpStartDate), EmpStartDate))
        FollowingMonth = DateSerial(Year(RetentionStartdate), Month(RetentionStartdate) + 1, 1)
        RetentionMonths = Months(FollowingMonth, Nz(EmpEndDate, Date))

End Function

I'm either getting crazy negative numbers in fields that used to work, or #Name? errors.

A:

you can check for the value of 0 for the end date by using clng
Public Function RetentionMonths(ByVal EmpStartDate As Date, _
    Optional ByVal EmpEndDate As Date) _
    As Integer

    Dim RetentionStartdate As Date
    Dim FollowingMonth As Date
    Dim tempEndDate As Date

    If CLng(EmpEndDate) = 0 Then EmpEndDate = Now()

        RetentionStartdate = DateAdd("ww", 14, DateAdd("d", vbSaturday - Weekday(EmpStartDate), EmpStartDate))
        FollowingMonth = DateSerial(Year(RetentionStartdate), Month(RetentionStartdate) + 1, 1)
        RetentionMonths = Months(FollowingMonth, Nz(EmpEndDate, Date))

End Function

