You need to do one of two things.....set the properties on the field to
"allow Zero Length" = yes....
or
change your if statement to:
<cfif isDefined("form.MiddleInit") and form.MiddleInit is not ""><cfset
MiddleInit = "#form.MiddleInit#"><cfelse><cfset MiddleInit=" "></cfif>
and move it outside the insert query
It's much easier to change the field property :)
HTH
D
*************
Diana Nichols
Webmistress
http://www.lavenderthreads.com
770.434.7374
"One man's magic is another man's engineering." ---Lazarus Long
-----Original Message-----
From: Hubert Earl [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 29, 2001 11:53 AM
To: CF-Talk
Subject: Re: How can I get CF to ignore a form field with no data?
Hi Bill,
Thanks for the advice. However, when I made the changes you suggested, I
still got this error message:
Error Diagnostic Information
ODBC Error Code = S1000 (General error)
[Microsoft][ODBC Microsoft Access Driver] Field 'Users.MiddleInit' cannot be
a zero-length string.
The error occurred while processing an element with a general identifier of
(CFQUERY), occupying document position (2:2) to (2:28).
The code I used was this:
<cfif isDefined("form.MiddleInit")
and form.MiddleInit is not "">
MiddleInit = '#form.MiddleInit #',
</cfif>
MiddleInit='#MiddleInit#',
Hubert
---
Hubert Earl
ICQ#: 16199853
AIM: hubertfme
My Jamaican Art, Craft & More Online Store:
http://www.angelfire.com/ny/hearl/link_page_on_angelfire.html
----- Original Message -----
From: "Bill Davidson" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Saturday, April 28, 2001 9:07 PM
Subject: Re: How can I get CF to ignore a form field with no data?
> Test it see if is blank or undefined with a cfif block in your SQL.
> Something like:
>
> <CFQUERY Name="update_query" datasource="#application.dsn#">
>
> Update table_name
> Set
> <cfif isDefined("form.MiddleInit ") and form.MiddleInit is not "">
> MiddleInit = '#form.MiddleInit #',
> </cfif>
> field = form.field
> ....
> Where
> ....
> </cfquery>
>
> -Bill
> www.brainbox.tv
>
> ----- Original Message -----
> From: "Hubert Earl" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Saturday, April 28, 2001 7:05 PM
> Subject: How can I get CF to ignore a form field with no data?
>
>
> > Hi,
> >
> > How can I get CF to ignore a form field with no data? I have a form with
a
> field called MiddleInit which will not always be filled in. At the
moment,
> however, an error message is generated if that field is blank.
> >
> > Sincerely,
> > ---
> > Hubert Earl
> >
> > ICQ#: 16199853
> > AIM: hubertfme
> >
> > My Jamaican Art, Craft & More Online Store:
> http://www.angelfire.com/ny/hearl/link_page_on_angelfire.html
> >
> >
> >
> >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists