
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.