Solved

DBGrid: This Action was Cancelled by an Associated Object

Posted on 1998-11-11
7
299 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no 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…
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

21 Experts available now in Live!

Get 1:1 Help Now