Solved

Mystic Error 3426

Posted on 1998-09-19
6
178 Views
Last Modified: 2010-04-30
I have a data control with 6 fields: 2 dates and 4 text fields, one of the latter is a filename.

I get the run-time error 3426 "This action was cancelled by an associated object". I'm using VB 5, and it has no documentation for that error. The error happens under the following circumstances:

1. A new database is created.
2. I use AddNew method on the recordset to create the very first record.
3. I fill some of the fields, among them the field with the filename.
4. The Update method is applied to the recordset.
5. I set the bookmark to the new record using ".Bookmark = .LastModified"

At that moment error 3426 happens.

Note that it does not happen if I don't fill the field with the filename or if the record is not the first.

0
Comment
Question by:karnovsk
  • 4
6 Comments
 

Author Comment

by:karnovsk
Comment Utility
Edited text of question
0
 

Author Comment

by:karnovsk
Comment Utility
Error 3426 was already discussed in Experts Exchange  in November 1997 (QID=10028427), but the answers given there don't help me.
0
 
LVL 2

Expert Comment

by:dabellei
Comment Utility
before doing your bookmark try to do a movelast this will repositionned you to the same record and then your bookmark will work
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:karnovsk
Comment Utility
Neither MoveLast nor MoveFirst help. Both generate the same error 3426.

General comment: I would be very grateful for a good workaround, but I would also like to get an indepth explanation of error 3426. Actually I am afraid that it is a Microsoft bug.
0
 
LVL 1

Accepted Solution

by:
steve06 earned 200 total points
Comment Utility
From Microsoft site (it's not a bug, it's a feature!)

The information in this article applies to:
Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0
Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 16-bit and 32-bit, for Windows, version 4.0


SYMPTOMS
This article discusses the error message "This action was cancelled by an associated object." that Visual Basic generates when working with Access databases and the Data control. This article does not apply to the ADO data control.



CAUSE
This error is being generated because the AddNew command of a bound recordset causes Visual Basic to try to save the current record if the data has changed. Because the data control is currently pointing to a NULL record and not an empty record, the data cannot be saved so the "action was cancelled by an associated object" error is reported. This is commonly seen when using the data form wizard in Visual Basic versions 4.0 and 5.0. The data form wizard in Visual Basic 6.0 generates code for the ADO data control so this error is less likely to occur.



RESOLUTION
Check the underlying recordset to see if either the BOF or EOF properties are True before allowing an implicit save to occur. An implicit save occurs either when using the data control to navigate off of a record where the information has changed or adding a record to a bound recordset.



STATUS
This behavior is by design.



MORE INFORMATION


Steps to Reproduce Behavior

Create a new Visual Basic Standard EXE project. Form1 is created by default.

Add the following controls to Form1:

      Control Type        Control Name         Caption
      ------------        ------------         -------
      Data                datDataCtl
      Text Box            txtCategory
      Command Button      cmdAddNew            Add
      Command Button      cmdMoveVeryLast      Move Very Last


Cut and paste the following code into the code window of the form:


      Option Explicit


      Private Sub cmdAddNew_Click()

          'Uncomment this block to avoid 3426 error message
          ' Check to see you are on NULL Pointer
          'If datDataCtl.Recordset.EOF Or datDataCtl.Recordset.BOF Then

              'Dim strBuffer As String

              ' Save what was typed into the text box into memory
              'strBuffer = txtCategory.Text

              ' Restore text box value to the original record contents
              ' in this case, that is NULL
              'datDataCtl.UpdateControls

              ' Add a new blank record
              'datDataCtl.Recordset.AddNew

              ' Restore what has been typed from memory to text box
              'txtCategory.Text = strBuffer

              ' Save the current record we are on and Add a new blank
              ' record
              'datDataCtl.Recordset.AddNew

          'End If

          ' be sure to comment below line when uncommenting above block of
          ' code to avoid an additional record added to the recordset.
          datDataCtl.Recordset.AddNew

      End Sub

      Private Sub cmdMoveVeryLast_Click()

        If Not (datDataCtl.Recordset.BOF Or datDataCtl.Recordset.EOF) Then
          datDataCtl.Recordset.MoveLast
          datDataCtl.Recordset.MoveNext
        End If

      End Sub

      Private Sub Form_Load()

          With datDataCtl
            .DatabaseName = App.Path & "\NWIND.MDB"
            .RecordSource = "Categories"
          End With

          txtCategory.DataField = "CategoryName"

      End Sub


While in the form's design view, set txtCategory's DataSource property equal to datDataCtl.

Run the form. To reproduce the data, click on the Move Very Last CommanButton, type any data into the text box, and then click on the Add CommandButton.

Note error: uncomment the above code sample to avoid the error.

Best regards,
Steve06
0
 

Author Comment

by:karnovsk
Comment Utility
Thank you very much, steve06! I was looking for that type of an answer!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now