Date

ariel81

Registered User.
Local time
Today, 15:44
Joined
Dec 31, 2006
Messages
75
i have a statement like this:
Code:
Dim TempDate As Date

TempDate = ReportDay & "/" & h!txtMthNum & "/" & h!txtSqnReportYear

during program run time there will be a run time error '13' (type mismatch).
in debug mode, the values inside are:


ReportDay = 30 (correct)
h!txtMthNum = 2 (correct)
h!txtSqnReportYear = 2007 (correct)
TempDate = 12:00:00 AM (wrong)

TempDate value is 12:00:00 AM (wrong) instead of "30/2/2007" for TempDate.
is there anything wrong in my statement?
 
Set it using
TempDate = "#" & ReportDay & "/" & h!txtMthNum & "/" & h!txtSqnReportYear & "#"
 
it doesn't work...

here is the full statement
Code:
Dim TempDate As String
Dim FindDate As Date

 TempDate = ReportDay & "/" & h!txtMthNum & "/" & h!txtSqnReportYear
               FindDate = Format((TempDate), "mm/dd/yyyy")
               rst.FindFirst "InputDate = #" & FindDate & "#"

the debug mode hightlighted this statement:
Code:
FindDate = Format((TempDate), "mm/dd/yyyy")

values inside FindDate = 12:00:00 AM (Wrong)
values inside TempDate = "29/2/2007"
 
i put a IsDate and its solved
Code:
 If IsDate(TempDate) Then
                 FindDate = Format((TempDate), "mm/dd/yyyy")
 

Users who are viewing this thread

Back
Top Bottom