Error 3426 with Null Bound Combo Box Field. 
Author Message
 Error 3426 with Null Bound Combo Box Field.

I have a VB 4.0 form with an Access 2.0 Database. I have several combo
boxes that are linked to secondary tables to edit values that are input.
These values are numeric values like 103, 105, 221 etc. The rule is that
the value has to be in the table or null. The problem is, that if I hit the
delete key on that combo box field, it nulls the entry, but then when I
advance to another record, I get the following error message:

Run-time error '3426'.

The action was cancelled by an associated object.

The error occurs on the MoveNext instruction.

This is really{*filter*} me up. Any help would be greatly appreciated. I want
to be able to put in nothing, or a valid value off of the secondary table.
It works fine as long as I leave the box alone, or use a valid value.
Thanks,



Sun, 21 Feb 1999 03:00:00 GMT  
 Error 3426 with Null Bound Combo Box Field.

Quote:

>I have a VB 4.0 form with an Access 2.0 Database. I have several combo
>boxes that are linked to secondary tables to edit values that are input.
>These values are numeric values like 103, 105, 221 etc. The rule is that
>the value has to be in the table or null. The problem is, that if I hit the
>delete key on that combo box field, it nulls the entry, but then when I
>advance to another record, I get the following error message:
>Run-time error '3426'.

>The action was cancelled by an associated object.
>The error occurs on the MoveNext instruction.
>This is really{*filter*} me up. Any help would be greatly appreciated. I want
>to be able to put in nothing, or a valid value off of the secondary table.
>It works fine as long as I leave the box alone, or use a valid value.
>Thanks,


Here's an article from VBTT:

Fix for VB4 Data Control Errors 3020 & 3426

The following code, which works fine under VB3, may generate runtime Error 3426 -- "The action was
cancelled by an associated object" -- in the 16-bit version of VB4 (the code also errors out under
VB4/32, but with the more-accurate Error 3020 -- "Update or CancelUpdate without AddNew or Edit"):

Private Sub cmdUpdate_Click()
        'Save contents of bound controls
        'to underlying recordset
        datCtl.Recordset.Update
End Sub

The problem seems to be caused by the fact that, unlike VB3, VB4 does not perform an implicit Edit
method whenever the Data Control moves to a new record. The solution is to check the recordset's
EditMode and perform an explicit Edit method if necessary:

Private Sub cmdUpdate_Click()
        If datCtl.Recordset.EditMode = dbEditNone Then
                datCtl.Recordset.Edit
        End If

        datCtl.Recordset.Update

End Sub

Another workaround is to replace the Update method with the Data Control's UpdateRecord method
(datCtl.UpdateRecord), which is functionally equivalent to performing an Edit followed by an Update.
The drawback is that UpdateRecord does not fire a Validate event, so you shouldn't use it if you
rely on that event to perform data validation.

--
Datrix (Musician, Coder)
http://www.*-*-*.com/ ~w-10256/datrix.htm
    Big artists info page available at      
http://www.*-*-*.com/ ~w-10256/artists.htm



Mon, 22 Feb 1999 03:00:00 GMT  
 Error 3426 with Null Bound Combo Box Field.

Quote:

> >I have a VB 4.0 form with an Access 2.0 Database. I have several combo
> >boxes that are linked to secondary tables to edit values that are input.
> >These values are numeric values like 103, 105, 221 etc. The rule is that
> >the value has to be in the table or null. The problem is, that if I hit
the
> >delete key on that combo box field, it nulls the entry, but then when I
> >advance to another record, I get the following error message:

> >Run-time error '3426'.

> >The action was cancelled by an associated object.

> >The error occurs on the MoveNext instruction.

> >This is really{*filter*} me up. Any help would be greatly appreciated. I
want
> >to be able to put in nothing, or a valid value off of the secondary
table.
> >It works fine as long as I leave the box alone, or use a valid value.
> >Thanks,

> Here's an article from VBTT:

> Fix for VB4 Data Control Errors 3020 & 3426

> The following code, which works fine under VB3, may generate runtime

Error 3426 -- "The action was
Quote:
> cancelled by an associated object" -- in the 16-bit version of VB4 (the

code also errors out under
Quote:
> VB4/32, but with the more-accurate Error 3020 -- "Update or CancelUpdate

without AddNew or Edit"):
Quote:

> Private Sub cmdUpdate_Click()
>    'Save contents of bound controls
>    'to underlying recordset
>    datCtl.Recordset.Update
> End Sub

> The problem seems to be caused by the fact that, unlike VB3, VB4 does not

perform an implicit Edit
Quote:
> method whenever the Data Control moves to a new record. The solution is

to check the recordset's
Quote:
> EditMode and perform an explicit Edit method if necessary:

> Private Sub cmdUpdate_Click()
>    If datCtl.Recordset.EditMode = dbEditNone Then
>            datCtl.Recordset.Edit
>    End If

>    datCtl.Recordset.Update

> End Sub

> Another workaround is to replace the Update method with the Data

Control's UpdateRecord method
Quote:
> (datCtl.UpdateRecord), which is functionally equivalent to performing an

Edit followed by an Update.
Quote:
> The drawback is that UpdateRecord does not fire a Validate event, so you

shouldn't use it if you
Quote:
> rely on that event to perform data validation.

> --
> Datrix (Musician, Coder)
> http://www.*-*-*.com/ ~w-10256/datrix.htm
>     Big artists info page available at      
> http://www.*-*-*.com/ ~w-10256/artists.htm

I checked this out, but the only time I get the error is when I have a null
value in the bound combo box. If I put in a value, it works. This all
happens when I go to another record after nulling out the combo box by
pressing the <delete> key. If I put in a value, it all works with no need
to do any edit or anything else.


Fri, 26 Feb 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Error 3426 with Null Bound Combo Box Field.

2. Null values in a bound data combo box

3. Null Values in Data Bound Combo Boxes

4. Combo Box like Data Bound Combo Box?

5. Bound combo box that does not display key field

6. Database Error No. 3426 (VB 5) / Datenbankfehler 3426 (VB 5)

7. Zero Length Fields and Error 3426 Questions, Please.

8. Bound combo box won't let be cancel/undo, continually generating error messages

9. Bound Combo Box style 2 Error

10. Data Bound Combo Box within a Data Bound Grid

11. Errors with Text Box bound to Date Field

12. Combo Binding - Null value

 

 
Powered by phpBB® Forum Software