G
Guest
Hopefully this will be an easy one for someone..........
I have a stored parameter query (named exec SPQ_TS_Ins) that I want to
execute from elsewhere (Excel). The SQL is:
INSERT INTO BbookedHrs ( YrWeekNo, JobNo, TaskNo, Mmonday, Ttuesday,
Wwednesday, Tthursday, Ffriday, SatSun )
VALUES ([P1], [P2], [P3], [P4], [P5], [P6], [P7], [P8], [P9]);
and the VBA in Excel is:
Conn.Execute "exec SPQ_TS_Ins " & _
Range("weekno").Value & "," & Range("jobno" & r).Value & ","
& _
Range("taskno" & r).Value & "," & Range("mon" & r).Value &
"," & _
Range("tue" & r).Value & "," & Range("wed" & r).Value & ","
& _
Range("thu" & r).Value & "," & Range("fri" & r).Value & ","
& _
Range("we" & r).Value
where Conn is the ADO connection to the database and the parameters are the
evaluation of worksheet cells.
This works just fine except when some of the cells in Excel are left blank
at which point the SQL fails. Any ideas how I can handle the situation when
cells are blank?
All contributions greatly appreciated.
Thanks
I have a stored parameter query (named exec SPQ_TS_Ins) that I want to
execute from elsewhere (Excel). The SQL is:
INSERT INTO BbookedHrs ( YrWeekNo, JobNo, TaskNo, Mmonday, Ttuesday,
Wwednesday, Tthursday, Ffriday, SatSun )
VALUES ([P1], [P2], [P3], [P4], [P5], [P6], [P7], [P8], [P9]);
and the VBA in Excel is:
Conn.Execute "exec SPQ_TS_Ins " & _
Range("weekno").Value & "," & Range("jobno" & r).Value & ","
& _
Range("taskno" & r).Value & "," & Range("mon" & r).Value &
"," & _
Range("tue" & r).Value & "," & Range("wed" & r).Value & ","
& _
Range("thu" & r).Value & "," & Range("fri" & r).Value & ","
& _
Range("we" & r).Value
where Conn is the ADO connection to the database and the parameters are the
evaluation of worksheet cells.
This works just fine except when some of the cells in Excel are left blank
at which point the SQL fails. Any ideas how I can handle the situation when
cells are blank?
All contributions greatly appreciated.
Thanks