Taking a quick look, I can't see anywhere where you give quoteReq_char a value so it will always be blank.
Assuming you are giving it a value, then changing this:-
toCode:If Val("" & QuoteReq_char) = 0 Then SQL = SQL & ", '" & Null & "'" Else SQL = SQL & ", CONVERT(datetime,'" & Format(QuoteReq_char, "MM-DD-YYYY") & "', 103)" End If
you'll also need to do something similar with ToCarrier_char. The point is you're building up a string. If you build a vb null (which is an empty string) into it you'll just get a blank so your string will look something like 'SomeVal', '', 'SomeOtherVal'. But if you pass "NULL" as a string then the string will read 'SomeVal', NULL, 'SomeOtherVal' and that's what sql server wants. Does that make sense?Code:If Val("" & QuoteReq_char) = 0 Then SQL = SQL & ", Null " Else SQL = SQL & ", CONVERT(datetime,'" & Format(QuoteReq_char, "MM-DD-YYYY") & "', 103)" End If
I'm not familiar with this:-
If Val("" & QuoteReq_char) = 0
to check for an empty string but I think it should work. I'd suggest:-
If QuoteReq_char = ""
or
If len(QuoteReq_char) = 0
are more readable though.




Reply With Quote