
how to handle NULL values from a FORM when using date string functions - help please
wow... three great replies!
Thanks so very much!
This forum has always provided me with great assistance and I sincerely
appreciate it.
-Lucy
Quote:
> Hello,
> There are three philosophies covered in a number of ASP programming books
on
> this topic:
> 1] simply conconcatenate an empty string to the value
> e.g.,
dtInspection_Date=DateValue(CDate(Request.Form("Inspection_Date") &
Quote:
> "" ))
> 2] VBScript has a built-in function that can determine if a variable is
holding
> a NULL variable
> e.g., If IsNull (Request.Form("Inspection_Date"))
> 3] You could implement Client-side scripting and use the built-in IsDate
> function or other logic to check and clean things up.
> Regards,
> > Hi Lucy,
> > I do not use ASP but basic IF logic should be the solution. If the form
> > data value is not null or blank then assign the vale to the variable.
> > Otherwise, assign the variable a blank value. Something like this should
do
> > it:
> > If (Request.Form("Inspection_Date") not equal "")
> > dtInspection_Date=DateValue(CDate(Request.Form("Inspection_Date")))
> > Else
> > dtInspection_Date=""
> > EndIf
> > Hope this helps,
> > CEF
> > > Below is a section from my ASP code that is called from a FORM.
> > > The form requests some dates and times from the user.
> > > As long as there is a value entered, the database is updated
perfectly.
> > > However, when the user omits the date and time (as in there is no
auction
> > > happening, so
> > > there is no date or time values entered), I get an error:
> > > =================================
> > > Microsoft VBScript runtime error '800a000d'
> > > Type mismatch: 'CDate'
> > > /update-res.asp, line 35
> > > =================================
> > > Here is the code - line 35 is the first one listed below:
> > > =================================
> > > dtAuction_Date=DateValue(CDate(Request.Form("Auction_Date")))
> > > dtAuction_Time=TimeValue(CDate(Request.Form("Auction_Time")))
> > > dtInspection_Date=DateValue(CDate(Request.Form("Inspection_Date")))
> > > dtInspection_Time=TimeValue(CDate(Request.Form("Inspection_Time")))
> > > =================================
> > > How do I allow a null value to be entered?
> > > Thanks!
> > > -Lucy