Solved

What does 'cancelled by an associated object mean'?

Posted on 2003-11-18
8
274 Views
Last Modified: 2010-04-17
I have a simple if/then/else statement but for some reason when it gets down to the else part, a debug comes up on the update line of code saying 'action cancelled by associated object'. I just cant understand why. It is exactly the same as the top half of the code and that works fine. Please can anyone help? Thanks


If Check1.Value = 0 Then
        Data1.Recordset.Edit
        Check1.BackColor = &H8080FF
        Shape37.BackColor = &H8080FF
        Text3.Enabled = False
        Text5.Enabled = False
        Text6.Enabled = False
        Text7.Enabled = False
        Text8.Enabled = False
        Text10.Enabled = False
        Text11.Enabled = False
        Text12.Enabled = False
        Text13.Enabled = False
        Text17.Enabled = False
        Text18.Enabled = False
        Command6.Enabled = False
        mnunewnote.Enabled = False
        mnufileedit.Enabled = False
        Text2.Enabled = False
        Text19.Enabled = False
        Text20.Enabled = False
        Text21.Enabled = False
        Text22.Enabled = False
        Text23.Enabled = False
        Data1.Recordset.Update
    Else
        Data1.Recordset.Edit
        Check1.BackColor = &HC0FFC0
        Shape37.BackColor = &HC0FFC0
        Text3.Enabled = True
        Text5.Enabled = True
        Text6.Enabled = True
        Text7.Enabled = True
        Text8.Enabled = True
        Text10.Enabled = True
        Text11.Enabled = True
        Text12.Enabled = True
        Text13.Enabled = True
        Text17.Enabled = True
        Text18.Enabled = True
        Command6.Enabled = True
        mnufile.Enabled = True
        Text2.Enabled = True
        Text19.Enabled = True
        Text20.Enabled = True
        Text21.Enabled = True
        Text22.Enabled = True
        Text23.Enabled = True
        mnunewnote.Enabled = True
        mnufileedit.Enabled = True
        Data1.Recordset.Update
    End If
0
Comment
Question by:matt_fennell
  • 3
  • 2
  • 2
8 Comments
 
LVL 18

Expert Comment

by:Cluskitt
ID: 9771228
On which line exactly does the error occur? Most likely you have 2 associated objects and one is trying to perform an action that isn't permitted by the other. It would help to get more information, like what objects are you loading in the form?
0
 

Author Comment

by:matt_fennell
ID: 9771486
The error occurs on the last line before the end if, the data1.recordset.update. Im not too sure what you mean by loading 'what objects am I loading on the form'. You'll have to forgive me, am quite a beginner programmer. As far as I can see, theres no logical explanation why this action is not updating.

It is used simply a check box which when clicked, it either makes the data active or inactive. It links to a yes/no field in Access.

This also occurs when adding a new user on a seperate screen:
Add/delete screen:

 'Updates the database with the new user
   
    If Text1.Text = "" Or Text3.Text = "" Then
            MSG = "Please enter Username, employee type and password of new user"    ' Define message.
            Style = vbExclamation                      ' Define buttons.
            Title = "Enter details"                 ' Define title.
            responce = MsgBox(MSG, Style, Title)
            Text1.SetFocus
            'Data1.Recordset.MoveFirst
            cmdOk.Enabled = False
            Command7.Enabled = True
            Command1.Enabled = False
            Command2.Enabled = False
       
        Else
            If Text4.Text = Text3.Text Then
                'Data1.Recordset.Update
                Data1.Refresh
                MsgBox ("User added")
                cmdOk.Enabled = False
                Text4.Text = ""
                Text1.Locked = True
                Text2.Locked = True
                Text3.Locked = True
                Text4.Locked = True
            Else
                MsgBox ("Confirmed password incorrect. Please confirm again")
                Text3.Text = ""
                Text4.Text = ""
                Text3.SetFocus
                Command1.Enabled = False
                Command2.Enabled = False
            End If
    End If
   
   
    Command1.Enabled = True
    Command2.Enabled = True
   
    Command7.Enabled = False
   
End Sub

Private Sub Command1_Click()
    Text1.Locked = False
    Text2.Locked = False
    Text3.Locked = False
    Text4.Locked = False
    Data1.Recordset.AddNew
    Data1.Recordset.Edit
    Text1.SetFocus
    Command1.Enabled = False
    Command2.Enabled = False
    cmdOk.Enabled = True
    Command7.Enabled = True
End Sub

Private Sub Command2_Click()
   
    'purpose - delete the selected user
    Label5.Caption = Text1.Text
    Frame5.Visible = True
End Sub

Private Sub Command3_Click()
    End
End Sub

Private Sub Command4_Click()
    menu.Show
    Addordelete.Hide
End Sub

Private Sub Command5_Click()
    Frame5.Visible = False
    Label5.Caption = ""
End Sub

Private Sub Command6_Click()
    'Data1.Recordset.Edit
    Data1.Recordset.Delete
    'Data1.Recordset.Update
    Data1.Refresh
    MsgBox ("User deleted")
    Frame5.Visible = False
    Label5.Caption = ""
End Sub

Private Sub Command7_Click()
    'Text1.Text = ""
    'Text2.Text = ""
    'Text3.Text = ""
    Data1.Recordset.Delete
    Data1.Recordset.Update
    Data1.Refresh
    cmdOk.Enabled = False
    Data1.Recordset.MoveFirst
    Command1.Enabled = True
    Command2.Enabled = True
    Command7.Enabled = False
    Text1.Locked = True
    Text2.Locked = True
    Text3.Locked = True
    Text4.Locked = True
End Sub

Private Sub mnuadd_Click()
    Text1.Locked = False
    Text2.Locked = False
    Text3.Locked = False
    Text4.Locked = False
    Data1.Recordset.AddNew
    Text1.SetFocus
    Command1.Enabled = False
    Command2.Enabled = False
    cmdOk.Enabled = True
    Command7.Enabled = True
End Sub

Again, same msg. When click ok, 'action cancelled by associated object'. Update line again.
0
 
LVL 15

Accepted Solution

by:
SRigney earned 20 total points
ID: 9771505
My best guess as to the failure is that the Data1 is using a field on the screen somewhere that it doesn't like, so when it tries to update it there is a problem.  But the problem only exists when the checkbox is checked.  The code itself is not the problem, but probably the data in that circumstance.

Here is a slightly modified chunk of code that will reduce the amount of code you are using.

Dim lngColor as Long
Dim blnEnabled as Boolean
lngColor = IIf(Check1.Value = 0, &H8080FF, &HC0FFC0)
blnEnabled = (Check1.Value = 0)

        Data1.Recordset.Edit
        Check1.BackColor = lngColor
        Shape37.BackColor = lngColor
        Text3.Enabled = blnEnabled
        Text5.Enabled = blnEnabled
        Text6.Enabled = blnEnabled
        Text7.Enabled = blnEnabled
        Text8.Enabled = blnEnabled
        Text10.Enabled = blnEnabled
        Text11.Enabled = blnEnabled
        Text12.Enabled = blnEnabled
        Text13.Enabled = blnEnabled
        Text17.Enabled = blnEnabled
        Text18.Enabled = blnEnabled
        Command6.Enabled = blnEnabled
        mnunewnote.Enabled = blnEnabled
        mnufileedit.Enabled = blnEnabled
        Text2.Enabled = blnEnabled
        Text19.Enabled = blnEnabled
        Text20.Enabled = blnEnabled
        Text21.Enabled = blnEnabled
        Text22.Enabled = blnEnabled
        Text23.Enabled = blnEnabled
        Data1.Recordset.Update
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:matt_fennell
ID: 9771567
I dont know if its any help, but I copied and pasted that piece of code into my program and now it pulls up the error as soon as I try to load the form. Before I even try and interact with the check box
0
 
LVL 18

Expert Comment

by:Cluskitt
ID: 9771833
One thing you should always do is rename the controls into names that are easily understandable. Like cmdEnd, txtPassword, txtConfirmPass, etc... It makes your code a lot easier to read and understand. Anyway, an object is anything you load on your form, which is also an object. Also, your database is an object, and that is where the problem must be. Maybe you are trying to insert a different data type and the database won't allow it. If the error is in the data1.recordset.update, then I would say it definitely is the problem. By what I could understand of the code, I would assume that your text boxes are linked to the database, right?
Try to post the way your database is defined (which tables, fields, data types, etc.) and which object links to where.
You can try checking all the textboxes and see if the connection is set up right. Also check if you have permission to write in the database. Make a simple program to read/write a single line, directly into the database (without user input) for debugging purposes. Then report back to us if your problem isn't solved! ;)
0
 

Author Comment

by:matt_fennell
ID: 9772031
I understand that I havent made things greatly easy for myself by not naming command boxes etc. But I just cant understand why it wont work. Its one line saying edit followed by another saying update. Its just VB being a bitch as per usual. I really cant give you any more info Im afraid. The form itself is just too big. I have made sure I can write to the database because there are other commands that allow editing and deletion etc and even adding new dealers. Thank you for your help but the problem remains.
0
 
LVL 15

Expert Comment

by:SRigney
ID: 9772391
Again I think it's happening because you are trying to update the database with a value that it does not like.

Does adding error handling give you any more information about the problem?
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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

707 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

13 Experts available now in Live!

Get 1:1 Help Now