Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having problems with DoCmd.RunSQL

Status
Not open for further replies.

SiberBob

Programmer
Aug 28, 2002
107
0
0
US
I am having a problem with a DoCmd.RunSQL strSQL working in some instances and not in others...

When the time provided in Me.txtBlockTime is either 10:00 or 14:00 the code fails. When the time is any other time it works. I have looked at the table and confirmed that records exist with the times of 10:00, 11:00, 14:00 and 15:00 as indicated in my tests. Those records exist and

Here is my code:
Code:
            strSQL = "UPDATE MVIAppointments SET [ApptName] = '" & UCase(Me.txtReasonBlocked) & "', "
            strSQL = strSQL & "[ApptReserved] = True, "
            strSQL = strSQL & "[ApptCity] = '" & UCase(Me.txtReasonBlocked) & "', "
            strSQL = strSQL & "[ApptEmail] = '" & UCase(Me.txtReasonBlocked) & "'"
            strSQL = strSQL & " WHERE ([ApptDate] = #" & Me.calBlockDate & "#"
            strSQL = strSQL & " and [ApptTime] = #" & Format(Me.txtBlockTime, "h:mm:ss") & "#)"
            Debug.Print strSQL
            DoCmd.RunSQL strSQL

and here is a copy of the debug.print from 3 instances of running that code
Code:
UPDATE MVIAppointments SET [ApptName] = 'TEST', [ApptReserved] = True, [ApptCity] = 'TEST', [ApptEmail] = 'TEST' WHERE ([ApptDate] = #2/14/2008# and [ApptTime] = #14:00:00#)
UPDATE MVIAppointments SET [ApptName] = 'TEST', [ApptReserved] = True, [ApptCity] = 'TEST', [ApptEmail] = 'TEST' WHERE ([ApptDate] = #2/14/2008# and [ApptTime] = #15:00:00#)
UPDATE MVIAppointments SET [ApptName] = 'TEST', [ApptReserved] = True, [ApptCity] = 'TEST', [ApptEmail] = 'TEST' WHERE ([ApptDate] = #2/14/2008# and [ApptTime] = #11:00:00#)
UPDATE MVIAppointments SET [ApptName] = 'TEST', [ApptReserved] = True, [ApptCity] = 'TEST', [ApptEmail] = 'TEST' WHERE ([ApptDate] = #2/14/2008# and [ApptTime] = #10:00:00#)

Do you have any ideas why the sql statement would fail to work with at time of 10:00 or 14:00?

Thanks,

Bob
 
Did you look at the seconds for the times in the table?

ck1999
 
Yes. Actually the only time values allowed (entered by Update SQL statements) are 8:15 10:00 11:00 13:00 14:00 15:00

I can get the code above to work with either format of h:mm or h:mm:ss... as long as the time existing value in the table any existing value besides 10:00 or 14:00
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top