Solved

DBGrid: This Action was Cancelled by an Associated Object

Posted on 1998-11-11
7
302 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

807 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