title: Upcoming Date Function - Fixing Errors
body: <p>I have the following code:</p>
  <pre><code>Public Function NextDate(date1 As Date, date2 As Date, date3 As Date) As Date
  
  Dim ClosestDate As Date
  
  If date1 &gt;= Date Then
      ClosestDate = date1
  ElseIf date2 &gt;= Date Then
      ClosestDate = date2
  ElseIf date3 &gt;= Date Then
      ClosestDate = date3
  End If
  
  NextDate = Format(ClosestDate, &quot;mm/dd/yyyy&quot;)
  
  End Function
  </code></pre>
  <p>Where date1 &lt;= date2 &lt;= date3</p>
  <p>Sometimes there are no dates being entered into the function and it returns #Error</p>
  <p>Sometimes all the dates entered into the function are in the past and it returns 12:00:00am</p>
  <p>What would I have to put in my code so that if there are no dates or all the dates are in the past then the function returns nothing (The cell looks blank)</p>
  <p>*I'm using VBA in MS Access</p>