Trouble Formatting Time

bconner

Registered User.
Local time
Today, 17:13
Joined
Dec 22, 2008
Messages
183
I have a form that allows a user to select a time from a combo box for scheduling a report. I keep getting a runtime error 13 type mismatch on the line in red below. What am I doing wrong? Any help is greatly appreciated.


Code:
Dim strHour As Integer
Dim strAmPm As String
Dim strSQL As String
Set db = CurrentDb
 
'dtCurDay = Weekday(Date)
 
If CheckSchedule = -1 Then
    strHour = Nz(DLookup("[HOUR]", "Tbl_Schedule_Times", "[TIME] = '" & cmb_Time & "'"), 0)
    strAmPm = Nz(DLookup("[AM_PM]", "Tbl_Schedule_Times", "[TIME] = '" & cmb_Time & "'"), "AM")
    strTime = "#" & strHour & ":00:00 " & strAmPm & "#"
    [COLOR=red]dtrunreport = Format(strTime, "hh:mm")[/COLOR]
    dtCurTime = Format(Time(), "hh:mm")
 
Assuming the red font fails, the line below it works.
The dtrunreport - is that a control? Since it is not dim above?
Would you use Me.dtrunreport to indicate that?

If that text box is bound to a data field that is of type date/time, it would appear that the text (string) returned is a mismatch.
 

Users who are viewing this thread

Back
Top Bottom