Empty Date Fields

Results 1 to 2 of 2

Thread: Empty Date Fields

  1. #1
    Join Date
    Dec 1969

    Default Empty Date Fields

    For the life of me I have not been able to find information on submitting blank date fields or resolving this problem. <BR><BR>I have a form with two date fields. One is required the other is optional. When the optional field is not used, the execution of the sql statement fails. I am connecting to an Access table.

  2. #2
    Join Date
    Dec 1969

    Default Must use keyword NULL

    SQL = "INSERT INTO table (..., dateField, ... ) VALUES( ..., NULL, ...)"<BR><BR>*LITERALLY* the word NULL. No quotes around it. No #...# around it.<BR><BR>So if you are building the INSERT string in VBS, something like:<BR><BR>&#060;%<BR>...<BR>SQL = "INSERT INTO table (numfldX, dateField, txtfldY) VALUES("<BR>SQL = SQL & Request("numericFormFieldX")<BR>If Trim(Request("optionalDateField")) = "" Then<BR>&nbsp; &nbsp; SQL = SQL & ",NULL"<BR>Else<BR>&nbsp; &nbsp; SQL = SQL & ",#" & Request("optionalDateField") & "#"<BR>End If<BR>SQL = SQL & "&#039;" & Request("textFormFieldY") & "&#039; )"<BR>...<BR>%&#062;<BR><BR>The other option: Set the default value for that field to NULL and allow it to be omitted (settings in the design table view in Access). Then don&#039;t even mention it in the list of fields to be inserted!<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts