Click to See Complete Forum and Search --> : Nulls in a Date field


lbenedic
November 12th, 1999, 02:40 PM
I need to load null values into a MSACCESS date field defined as DATETIME and my VB program is blowing up with an error code 3421 - Data type conversion error. Is there anyway to load null values into a field defined this way?

Regards,

Luanne Benedict

Aaron Young
November 13th, 1999, 12:26 AM
Have you actually tried using the Null Value? ,e.g.

private Sub Command1_Click()
Dim oDB as Database
Dim oRS as Recordset
set oDB = Workspaces(0).OpenDatabase("DB1.mdb")
set oRS = oDB.OpenRecordset("SELECT * FROM Table1 WHERE ID=0", dbOpenDynaset)
oRS.AddNew
oRS("DateTimeField") = null
oRS.Update
set oRS = nothing
oDB.Close
set oDB = nothing
End Sub





Aaron Young
Analyst Programmer
adyoung@win.bright.net
aarony@redwingsoftware.com

lbenedic
November 15th, 1999, 06:11 AM
No I hadn't tried that, but I did and it worked great. Why would rs.[datefield] = "" not work?

Regards,

Luanne Benedict

Roy H
November 15th, 1999, 05:38 PM
Luanne,

Because "" is not null, it's an empty string. Which are two entirely different things to Access. Date fields in Access will not accept an empty string...

lbenedic
November 16th, 1999, 06:16 AM
Thank you both for your help. It's much appreciated!

Regards,

Luanne Benedict