Unanswered: error in null or blank date field in select stmt
Help! Im a newbie in vba programmingand encountering errors thruout my access application on this particular issue.
I have an insert statement where Im taking data from a textbox with a date value on an unbound form and on my save pushbutton inserting the value into a table. Sometimes for this particular textbox (txtDOB.value) there is a date, and sometimes there is not. The field name in the table is named DOB. The table is Decedent.
My code is as follows (it is in the middle of the insert statement, so I'm just highlighting the particular line of code that is germaine:
strsql2 = strsql2 & IIF(ISNULL(txtDOB.value), " ' ' ", "#" & (txtdob.value & "#") & ", "
it works fine if the textbox isnt blank.
So, I tried this inside of my Insert statement.....
If Isnull(txtdob.value) or Len(trim(txtdob.value)) <1 then
strsql2 = strsql2 & "DOB = null" & ", "
strsql2 = strsql2 & "DOB = #" & txtdob.value & "#, "
That still gives me an error if the field/text box is blank. Again, it inserts correctly if the text box contains a date value. Any help in fixing the first line of of code or the above if..end if inside of my Insert statement would be greatly appreciated.