SQL server and value null with a datefield

sven2

Registered User.
Local time
Today, 01:28
Joined
Apr 28, 2007
Messages
297
Hello,

when I insert a new record in an SQL table like:

strSQL = strSQL & "'" & Me.txtdate & "' AS date, "

and the txtdate = null the result in the table for the field date = 0:00:00

This isn't the result I want because I use very often the command isnull in my query's.

How can I make it so that when the field txtdate is empty that also the recordfield date in the table stays empty after the insert?

Thanks in advance,
Sven.
 
If nz(Me.txtdate,"") <> "" Then strSQL = strSQL & "'" & Me.txtdate & "' AS date,"
 
Hello,

if I do it that way I get an error like:

the select list for the insert statement contains fewer items ...

A possible solution is to make 2 insert statements ...
1 with and 1 without the date ...

Is this the right way to solve this problem?

Best regards,
Sven.
 

Users who are viewing this thread

Back
Top Bottom