Solved

DBGrid: This Action was Cancelled by an Associated Object

Posted on 1998-11-11
7
303 Views
Last Modified: 2013-12-26
I am editing data entered into a DBGrid. When the data is bad I set Cancel to true in DBGrid_BeforeUpdate. OK so far. However I always get the "This Action was Cancelled by an Associated Object" message when I do this (title of messagebox = "DBGrid"). I cannot get rid of this message. The closest I have come to this is in the DBGrid_Error event when VB tells me the DataError parameter = 13689 (Err.Number = 0). I tried setting this to zero but I still get the message. Help!!!!!!!!! TIA, Ed.
0
Comment
Question by:schoon
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1488214
I' tryed and I get no error.
Are you using bound or unbound mode?
0
 

Expert Comment

by:Badder
ID: 1488215
My GOD!!!
It was happening to me all the time back then when I programmed in VBasic.
If I remember I've ended up the winner.
I chaged the names of all the objects in the same frame that referred to or had the same Name as the Data Control, except, of course THE DATA CONTROL!!!
Also, I trashed some code about the data control control that was not essential.
The damn message has disappeared!
Hope it works, good luck!
0
 

Expert Comment

by:Badder
ID: 1488216
My GOD!!!
It was happening to me all the time back then when I programmed in VBasic.
If I remember I've ended up the winner.
I chaged the names of all the objects in the same frame that referred to or had the same Name as the Data Control, except, of course THE DATA CONTROL!!!
Also, I trashed some code about the data control control that was not essential.
The damn message has disappeared!

Good Luck.

Badder.
Hope it works, good luck!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:schoon
ID: 1488217
fguerreiro_inix: It's bound.
Badder: I only have the grid and the datacontrol on the form.
Here's where I'm doing the editing:

Private Sub dbgComments_BeforeUpdate(Cancel As Integer)
    Dim sPassDate As String

    sPassDate = dbgComments.Columns(2).Text
    dbgComments.Columns(2).Text = gfs_VerifyDate(sPassDate)
    If Not basGeneral.DateValid = True Then
        MsgBox "Invalid Date", 48, "Error Message"
        Cancel = True
        Exit Sub
    End If
    If dbgComments.Columns(2).Text = "" Then
        MsgBox "You must enter a date"
        Cancel = True
        Exit Sub
    End If
    dbgComments.Columns(0).Text = CStr(m_SSN)
    dbgComments.Columns(1).Text = m_StDt
    Exit Sub
End Sub

0
 
LVL 3

Accepted Solution

by:
fguerreiro_inix earned 300 total points
ID: 1488218

Try this...

Private Sub dbgComments_BeforeUpdate(Cancel As Integer)
    Dim sPassDate As String

    sPassDate = dbgComments.Columns(2).Text
    dbgComments.Columns(2).Text = gfs_VerifyDate(sPassDate)
    If Not basGeneral.DateValid = True Then
        MsgBox "Invalid Date", 48, "Error Message"
        SendKeys "{ESC}"
        DoEvents
        exit sub
    End If
    If dbgComments.Columns(2).Text = "" Then
        MsgBox "You must enter a date"
        SendKeys "{ESC}"
        DoEvents
        Exit Sub
    End If
    dbgComments.Columns(0).Text = CStr(m_SSN)
    dbgComments.Columns(1).Text = m_StDt
    Exit Sub
End Sub

You must also put code in dbgComments_Error event to intercept the error.
And make
Response = 0      'to prevent from error message from dbgrid  


I've tried and it works, you must be carefull with treatment of the error in dbgComments_Error.

Hope this helps
Regards

0
 

Author Comment

by:schoon
ID: 1488219
Brilliant! It works! You, sir, are a genius. Thanks a bunch.
0
 

Expert Comment

by:sonalchouhan
ID: 2514174
thanks a lot it works superb


thanks a lot
please let me knwow how can u not allow the user to edit 3 columns out of 5 please help
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

749 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