I am using access 2010I have a sql statement to insert information into a table.
If I have dates in date fields, it works fine. If I don't fill one it, I get errors.
I've read the posts and tried what was suggested but still no success.
Can someone see what I'm doing wrong?
My default database is 2007-2016
I've also tried:
ssql = "INSERT INTO tblPermitInfo ( " & _
" permitno, issuedate)" & _
" VALUES ( " & _
" " & txtPermitNo & " , " & _
" " & IIf(txtIssueDate = 0, & "" & Null & "", "#" & txtIssueDate & "#") & ")"
and
ssql = "INSERT INTO tblPermitInfo ( " & _
" permitno, issuedate)" & _
" VALUES ( " & _
" " & txtPermitNo & " , " & _
" " & IIf(IsNull(txtIssueDate), & "" & Null & "", "#" & txtIssueDate & "#") & ")"
Original version (written under access 2003 and worked fine):
ssql = ssql + " VALUES (" & _
....
' " " & IIf(IsNull(txtIssueDate), "Null", txtIssueDate) & " , " & _
' " " & IIf(IsNull(txtExpireDate), "Null", txtExpireDate) & " , " & _
....
thanks
If I have dates in date fields, it works fine. If I don't fill one it, I get errors.
I've read the posts and tried what was suggested but still no success.
Can someone see what I'm doing wrong?
My default database is 2007-2016
Code:
ssql = "INSERT INTO tblPermitInfo ( " & _
" permitno, issuedate)" & _
" VALUES ( " & _
" " & txtPermitNo & " , " & _
" " & IIf(txtIssueDate = 0, Null, "#" & txtIssueDate & "#") & ")"
I've also tried:
ssql = "INSERT INTO tblPermitInfo ( " & _
" permitno, issuedate)" & _
" VALUES ( " & _
" " & txtPermitNo & " , " & _
" " & IIf(txtIssueDate = 0, & "" & Null & "", "#" & txtIssueDate & "#") & ")"
and
ssql = "INSERT INTO tblPermitInfo ( " & _
" permitno, issuedate)" & _
" VALUES ( " & _
" " & txtPermitNo & " , " & _
" " & IIf(IsNull(txtIssueDate), & "" & Null & "", "#" & txtIssueDate & "#") & ")"
Original version (written under access 2003 and worked fine):
ssql = ssql + " VALUES (" & _
....
' " " & IIf(IsNull(txtIssueDate), "Null", txtIssueDate) & " , " & _
' " " & IIf(IsNull(txtExpireDate), "Null", txtExpireDate) & " , " & _
....
thanks