how to handle NULL values from a FORM when using date string functions - help please 
Author Message
 how to handle NULL values from a FORM when using date string functions - help please

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



Thu, 02 Sep 2004 21:00:45 GMT  
 how to handle NULL values from a FORM when using date string functions - help please
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


Quote:
> 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



Fri, 03 Sep 2004 01:53:58 GMT  
 how to handle NULL values from a FORM when using date string functions - help please
Or

If  not ( IsNull( Request("Inspection_Date") ) )
    dtInspection_Date=DateValue(CDate(Request.Form("Inspection_Date")))
Else
    dtInspection_Date=""
End If


Quote:
> 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



Fri, 03 Sep 2004 02:12:47 GMT  
 how to handle NULL values from a FORM when using date string functions - help please
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") &
"" ))

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,

Quote:

> 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



Fri, 03 Sep 2004 02:15:56 GMT  
 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



Sat, 04 Sep 2004 08:44:10 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. how to handle NULL values from a FORM when using date string functions - help please

2. CURSOR HANDLE ERROR. HELP!!!

3. Units em Pascal

4. Sending null strings and NULL values

5. Function to Return String Value of Date

6. Null date values in Date/Time fields in Access DB

7. Differences between NULL, Empty String, Null String?

8. Help: Inserting null values into Jet database using ADO

9. passing fields from form to form, and handling a date field

10. Converting QUICKBOOKS data to DBF

11. Handling Null Values

12. Handling Null values in Formula Editor

 

 
Powered by phpBB® Forum Software