Bug In VB4? Won't accept zero length date. 
Author Message
 Bug In VB4? Won't accept zero length date.

(32Bit Version)
Problem:
Text box bound to a Date/Time field in an Access 7.0 table.  

When the date is erased (creating a zero length entry) VB (or the Jet
Engine?) won't accept it.  The data control will not move off the record
until a valid date is entered.  

Have had a  couple other experienced programmers in VB3 look at it.  
They are now concerned about porting their apps to VB4.  Any experience
with this.  Got it solved?
--
Rick Padelford
ROSCOE Systems



Sun, 30 Aug 1998 03:00:00 GMT  
 Bug In VB4? Won't accept zero length date.

Quote:

> (32Bit Version)
> Problem:
> Text box bound to a Date/Time field in an Access 7.0 table.

> When the date is erased (creating a zero length entry) VB (or the Jet
> Engine?) won't accept it.  The data control will not move off the record
> until a valid date is entered.

> Have had a  couple other experienced programmers in VB3 look at it.
> They are now concerned about porting their apps to VB4.  Any experience
> with this.  Got it solved?
> --
> Rick Padelford
> ROSCOE Systems

I posted a similar message March 11 and have received no replies.  You will
find this also happens with text boxes bound to text fields.  VB3 converted
zero-length strings to NULL; VB4 does not.  Look up V1xNullBehavior in the VB4
help file.  Microsoft advises not adding this property but instructs you to
modify your code to write NULLs instead of zero-length strings.  Funny... it's
their text boxes misbehaving.  I could not find a way to force a text box to
write a NULL any other way but to add the V1xNullBehavior=True to the
database.

I think this is a big enough issue that it should be in the FAQ or KB.



Mon, 31 Aug 1998 03:00:00 GMT  
 Bug In VB4? Won't accept zero length date.

Quote:

>(32Bit Version)
>Problem:
>Text box bound to a Date/Time field in an Access 7.0 table.  
>When the date is erased (creating a zero length entry) VB (or the Jet
>Engine?) won't accept it.  The data control will not move off the record
>until a valid date is entered.  
>Have had a  couple other experienced programmers in VB3 look at it.  
>They are now concerned about porting their apps to VB4.  Any experience
>with this.  Got it solved?
>--
>Rick Padelford
>ROSCOE Systems

Do you have a data rule in that table stating that the field can't be
zero length?  Just a thought.

--
Joel Cornell



Mon, 31 Aug 1998 03:00:00 GMT  
 Bug In VB4? Won't accept zero length date.

Quote:

>(32Bit Version)
>Problem:
>Text box bound to a Date/Time field in an Access 7.0 table.  
>When the date is erased (creating a zero length entry) VB (or the Jet
>Engine?) won't accept it.  The data control will not move off the record
>until a valid date is entered.  
>Have had a  couple other experienced programmers in VB3 look at it.  
>They are now concerned about porting their apps to VB4.  Any experience
>with this.  Got it solved?

Is the field part of your primary key??




Sat, 05 Sep 1998 03:00:00 GMT  
 Bug In VB4? Won't accept zero length date.

Quote:


>>When the date is erased (creating a zero length entry) VB (or the Jet
>>Engine?) won't accept it.  The data control will not move off the record
>>until a valid date is entered.  

  Beside being a primary key (possibly) is the field defined as being
required if it is there is your problem, just change that.
Hope it's that simple.


Sat, 12 Sep 1998 03:00:00 GMT  
 Bug In VB4? Won't accept zero length date.

Quote:



> >>When the date is erased (creating a zero length entry) VB (or the Jet
> >>Engine?) won't accept it.  The data control will not move off the record
> >>until a valid date is entered.

>   Beside being a primary key (possibly) is the field defined as being
> required if it is there is your problem, just change that.
> Hope it's that simple.

Thanks for the response.  Unfortunately it is not.  I finally ended up
calling Microsoft on this.  They inform me that this is an issue under
dispute (or investigation).  They gave me a workaround.  

1. Put a phony date in the text box so that the rest of bound data will
be saved.
2. Then set the underlying data field to Null to make data right.
3. Then set text box back to empty (if necessary).
Seems pretty hokie to me.  Hope a fix comes out.
--
Rick Padelford
ROSCOE Systems



Fri, 18 Sep 1998 03:00:00 GMT  
 Bug In VB4? Won't accept zero length date.

Quote:

> Thanks for the response.  Unfortunately it is not.  I finally ended up
> calling Microsoft on this.  They inform me that this is an issue under
> dispute (or investigation).  They gave me a workaround.
> 1. Put a phony date in the text box so that the rest of bound data will
> be saved.
> 2. Then set the underlying data field to Null to make data right.
> 3. Then set text box back to empty (if necessary).
> Seems pretty hokie to me.  Hope a fix comes out.

Where did they suggest placing this code?  I assume that #1 must be in the
Data1_Validate event.  I can't imagine where #2 and #3 belong.


Sat, 19 Sep 1998 03:00:00 GMT  
 Bug In VB4? Won't accept zero length date.
<original posts snipped>

After looking at this a little more, I found that the bug is
actually in the VB4 textbox.  The VB4 textbox writes a
zero-length string if the control is empty whereas the VB3
textbox wrires a NULL.  The date-time field in Access will not
accept a zero-length string, so the conversion fails.  BTW,
V1XNullBehavior does not help this situation.

My workaround is to use the enhanced edit control in Crescent's
QuickPak Pro.  It writes a NULL to the database if the date is
cleared.  I hope Crescent doesn't change this control to act
like VB4's textbox or all is lost!



Sat, 19 Sep 1998 03:00:00 GMT  
 Bug In VB4? Won't accept zero length date.

says...

Quote:


>> Thanks for the response.  Unfortunately it is not.  I finally ended up
>> calling Microsoft on this.  They inform me that this is an issue under
>> dispute (or investigation).  They gave me a workaround.

>> 1. Put a phony date in the text box so that the rest of bound data will
>> be saved.
>> 2. Then set the underlying data field to Null to make data right.
>> 3. Then set text box back to empty (if necessary).
>> Seems pretty hokie to me.  Hope a fix comes out.

>Where did they suggest placing this code?  I assume that #1 must be in the
>Data1_Validate event.  I can't imagine where #2 and #3 belong.

I lost a nights sleep over this one.  

You can't do #2 by referencing the data control recordset object (I have
tried).  You could probably do it with a SQL update or by using a DAO method.  

I found another solution that may be helpful to you.  In the GetFocus event of
the text box that will contain a date do an UpdateRecord on the data set and
place a BeginTrans.  In the LostFocus event, test to see if the text box text >
"".  If it is, do a Rollback.  If not, Do a CommitTrans.

This is hokey too, and for the moment I've decided to tell our users to 'Be
Careful' with date fields. (Unacceptable!)

Of course, this won't work for pre-existing dates.

Alan Norton          | Pecos SoftWare Works |   With land in your hand

(520) 886-1307       |   Visual Basic       |   then invest in the church
Tucson, AZ          \./                    \./  for your Heaven. Genesis-
                    /'\                    /'\  Get Em Out By Friday



Sat, 19 Sep 1998 03:00:00 GMT  
 Bug In VB4? Won't accept zero length date.

...snip...

Quote:
> I found another solution that may be helpful to you.  In the GetFocus event of
> the text box that will contain a date do an UpdateRecord on the data set and
> place a BeginTrans.  In the LostFocus event, test to see if the text box text >
> "".  If it is, do a Rollback.  If not, Do a CommitTrans.

> This is hokey too, and for the moment I've decided to tell our users to 'Be
> Careful' with date fields. (Unacceptable!)

> Of course, this won't work for pre-existing dates.

The problem with the UpdateRecord method is, by design, it does not trigger the validate event.  Any
coding in that event gets bypassed.  If you use UpdateRecord, code it in a Sub that invokes your
validation routine.

While I'm on the UpdateRecord topic, I spoke with Microsoft about Data1.RecordSet.Update.  In VB3, I
could execute that one line for the File-Save Record routine.  In VB4 it bombs.  I either have to invoke
a Data1.RecordSet.Edit first or use Data1.UpdateRecord instead (no validate).  I was hoping it was fixed
in VB4a.  The support person told me all this was "by design"; there is nothing to fix.  Has anyone run
across anything that addresses these changes from VB3 to VB4?  My tried-and-true VB3 database routines
no longer function in VB4.  It seems that if Microsoft intentionally designed VB4 to be different from
VB3, it would be clearly documented.



Sun, 20 Sep 1998 03:00:00 GMT  
 Bug In VB4? Won't accept zero length date.

Quote:


> > Thanks for the response.  Unfortunately it is not.  I finally ended up
> > calling Microsoft on this.  They inform me that this is an issue under
> > dispute (or investigation).  They gave me a workaround.

> > 1. Put a phony date in the text box so that the rest of bound data will
> > be saved.
> > 2. Then set the underlying data field to Null to make data right.
> > 3. Then set text box back to empty (if necessary).
> > Seems pretty hokie to me.  Hope a fix comes out.

> Where did they suggest placing this code?  I assume that #1 must be in the
> Data1_Validate event.  I can't imagine where #2 and #3 belong.

In the Validate event..  All #1, #2, and #3....  No kidding...    I set
up the text boxes as a Collection and just "For Each"'d through on each
step.  I was able to make it work.  (Not bad for a 3 week VB Newbie.)  I
just can't believe I had to do it.  
--
Rick Padelford
ROSCOE Systems


Sun, 20 Sep 1998 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. DAO 2.5 won't convert zero length string to null in date field

2. DAO 2.5 won't convert zero length string to null in date field

3. VB4.0 Field can't be a zero-length string

4. Please help: VB4 won't accept VBX

5. 'allow zero length' not working

6. Zero-Length Strings vs. NULL, Access Date Fields

7. Zero length strings, SQL Server6.0/VB4.0a and spaces

8. Zero length strings in vb4

9. Bound VB4 TextBoxs, Nulls and Zero-Length Strings

10. SQL created Field can't be zero-length

11. Form becomes active window but won't accept input with Wizard running behind it

12. Form becomes active window but won't accept input with Wizard running behind it

 

 
Powered by phpBB® Forum Software