J
jayklmno
I am trying to compare two fields... one is a textbox and the other is a cell
range.
textbox : tbDateOOCreated.Value
range : Range("Db_Updated").Value
I am loading them into date variables and making a comparison in an if
statement
CreateDt = tbDateOOCreated.Value
UpdateDt = Range("Db_Updated").Value
If CreateDt < UpdateDt Then
:: Code ::
end if
The problem I am having is, if they are dates, and the textbox value is
empty, I get a type mismatch error.
if I use a function to fix the value...
CreateDt = FixDate(tbDateOOCreated.Value)
UpdateDt = FixDate(Range("Db_Updated").Value)
Function...
Public Function FixDate(DumbDate As Variant) As Variant
Dim dAns As Variant
If Not IsDate(DumbDate) Then
dAns = Null
ElseIf CStr(DumbDate) = "12:00:00 AM" Then
dAns = Null
Else
dAns = CDate(DumbDate)
End If
FixDate = dAns
End Function
I tried using a Function to fix the date and load a Null, but I get an
invalid use of null.
How can I compare these two fields as dates?
Thanks for the help!
range.
textbox : tbDateOOCreated.Value
range : Range("Db_Updated").Value
I am loading them into date variables and making a comparison in an if
statement
CreateDt = tbDateOOCreated.Value
UpdateDt = Range("Db_Updated").Value
If CreateDt < UpdateDt Then
:: Code ::
end if
The problem I am having is, if they are dates, and the textbox value is
empty, I get a type mismatch error.
if I use a function to fix the value...
CreateDt = FixDate(tbDateOOCreated.Value)
UpdateDt = FixDate(Range("Db_Updated").Value)
Function...
Public Function FixDate(DumbDate As Variant) As Variant
Dim dAns As Variant
If Not IsDate(DumbDate) Then
dAns = Null
ElseIf CStr(DumbDate) = "12:00:00 AM" Then
dAns = Null
Else
dAns = CDate(DumbDate)
End If
FixDate = dAns
End Function
I tried using a Function to fix the date and load a Null, but I get an
invalid use of null.
How can I compare these two fields as dates?
Thanks for the help!