Assigning NULL value to date/time
new_learner | Posted 1:42am 18. March 2010 Server Time |
Hi All,
Could you please help with this one..i am not able to update a record, it gives me an error saying.."Data type mismatch in criteria expression". I am using access and i have table in which I have about 5 date fields, user may or may not enter date field..its not mandatory...
When i try to update a record..it does not let me and gives me the above error...if i enter the date value, it updates the record..it does not let me leave the field empty...any help on this is highly appreciated..
I am trying this but it does not work...
Code:
A1Date = request("ADate")
B1Date = request("Bdate")
C1Date = request("CCdate")
If A1Date="" then
rs1("ADate")=NULL
else
rs1("ADate") =A1Date
end if
If B1Date="" then
rs1("BDate")=NULL
else
rs1("BDate") =B1Date
end if
If C1Date="" then
rs1("CDate")=NULL
else
rs1("CDate") =C1Date
end if
and then i write a sql update query which will update the record...
SQL = "UPDATE Schedules SET "
sSQL = sSQL & "Release_Name = '" & Release_Name2 & "',"
sSQL = sSQL & "Change_Number = '" & Change_Number2 & "',"
sSQL = sSQL & "Task_Owner = '" & Task_Owner2 & "',"
sSQL = sSQL & "Change_Owner = '" & Change_Owner2 & "',"
sSQL = sSQL & "ADate = '" & ADate1 & "',"
sSQL = sSQL & "BDate = '" & BDate2 & "',"
sSQL = sSQL & "CDate = '" & CDate3 & "'"
sSQL = sSQL & "WHERE Release_Name ='" & session("keyword_org") & "'"
Below works when i try to add a new record...
rs1("ADate")="NULL"
but i am not sure how should i include that in the update query...
Please help... |