G
Guest
I am new to writing VBA and just wrote my first function. I am hoping
someone can look at my code. I can't figure out why I keep getting the loop
without a do error message. Thanks in advance to anyone who helps me out.
Here's the code:
Public Function TestSmallDateTime(datValue)
Dim varRetVal As Variant
Dim datTestSmallDateTime As Date
Dim datDefaultDate As Date
Dim datHighDate As Date
Dim datLowDate As Date
datLowDate = #1/1/1900#
datHighDate = #6/6/2079#
TestSmallDateTime = datValue
If datValue >= datLowDate And datValue <= datHighDate Then
TestSmallDateTime = datValue
Else
If datValue >= datHighDate Then
Do Until (datLowDate And datValue <= datHighDate = datValue)
MsgBox "You entered an invalid date!! Must be less than " &
DateAdd("y", 1, datHighDate), vbOKOnly, "Bad Date" & _
datValue = InputBox("Deduction Change Effective Date (mm/dd/yyyy)?
", "Deduction Change", Format$(DATE, "mm/dd/yyyy"))
Loop Until TestSmallDateTime = datValue
End If
End If
End Function
someone can look at my code. I can't figure out why I keep getting the loop
without a do error message. Thanks in advance to anyone who helps me out.
Here's the code:
Public Function TestSmallDateTime(datValue)
Dim varRetVal As Variant
Dim datTestSmallDateTime As Date
Dim datDefaultDate As Date
Dim datHighDate As Date
Dim datLowDate As Date
datLowDate = #1/1/1900#
datHighDate = #6/6/2079#
TestSmallDateTime = datValue
If datValue >= datLowDate And datValue <= datHighDate Then
TestSmallDateTime = datValue
Else
If datValue >= datHighDate Then
Do Until (datLowDate And datValue <= datHighDate = datValue)
MsgBox "You entered an invalid date!! Must be less than " &
DateAdd("y", 1, datHighDate), vbOKOnly, "Bad Date" & _
datValue = InputBox("Deduction Change Effective Date (mm/dd/yyyy)?
", "Deduction Change", Format$(DATE, "mm/dd/yyyy"))
Loop Until TestSmallDateTime = datValue
End If
End If
End Function