If you put these statements in a macro (I'm using an Excl project) .
dateInitDate = Date$
datInitDate.Value = DateAdd("d", 0, Date$)
datComplDate.Value = DateAdd("d", 90, Date$)
and then F8 to step thru the macro and mouse over any values you've stepped
past (to display their values at that time)...I cannot get the 1/9/2005 and
01-09-2005 to resolve to one format or the other:
UNTIL I PUT THEM IN A DIM STATEMENT as Dates.
But now these two subroutines don't update fields correctly (each triggered
by exiting one of the textboxes). Add 2 textboxes with names datInitDate and
datComplDat and see how changing values in a field is affected by exiting
the field--I get an error (they used to update):
Private Sub datInitDate_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim Dt, Dt2 As Date
On Error Resume Next
Dt = datInitDate
If Dt > DateSerial(1950, 1, 1) Then
' if properly formatted, puts date in Init Date (now the format here fails)
datInitDate = Format$(Dt, "mm-dd-yyyy")
' and 90 days later in Compl Date
Dt2 = DateAdd("d", 90, datInitDate)
datComplDate= Format$(Dt2, "mm-dd-yyyy")
Else
datInitDate.Text = ""
Beep
End If
End Sub
Private Sub datComplDate_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim Dt2 As Date
On Error Resume Next
Dt2 = DateValue(datComplDate)
If Dt2 > DateSerial(1950, 1, 1) Then
datComplDate = Format$(Dt2, "mm-dd-yyyy")
Else
datComplDate = ""
Beep
End If
End Sub