Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Mystic Error 3426

Posted on 1998-09-19
6
Medium Priority
?
190 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
ID: 1435632
Edited text of question
0
 

Author Comment

by:karnovsk
ID: 1435633
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
ID: 1435634
before doing your bookmark try to do a movelast this will repositionned you to the same record and then your bookmark will work
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:karnovsk
ID: 1435635
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 800 total points
ID: 1435636
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
ID: 1435637
Thank you very much, steve06! I was looking for that type of an answer!
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

963 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