Solved

what is adReason = 5 in ADODC_WillChangeRecord?

Posted on 2004-04-19
4
581 Views
Last Modified: 2007-12-19
I am trying to figure out exactly what the enumerations are for the adReason in the WillChangeRecord event of ADODC. Is there an easy way to print out the enumerations of a variable?  I can't figure out what adReason = 5 is

Private Sub Adodc4_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
   
    Debug.Print " -- " & adReason & " ";

    Select Case adReason
    Case adRsnUpdate
        Debug.Print "update"
    Case adRsnFirstChange
        Debug.Print "first"
    Case adRsnAddNew
        Debug.Print "new"
    Case adRsnDelete
        Debug.Print "delete"
    Case adRsnMove
        Debug.Print "move"
    Case adReason = adRsnUndoAddNew
        Debug.Print "undo Addnew"
    Case adReason = adRsnUndoAddNew
        Debug.Print "undo Addnew"
  Case adRsnAddNew
        Debug.Print "Addnew"
  Case adRsnClose
        Debug.Print "close"
  Case adRsnDelete
        Debug.Print "delete"
  Case adRsnRequery
    Debug.Print "requery"
  Case adRsnResynch
    Debug.Print "resynch"
  Case adRsnUndoDelete
          Debug.Print "undo delete"
  Case adRsnUndoUpdate
          Debug.Print "undo update"
    End Select
End Sub

0
Comment
Question by:brokeMyLegBiking
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 10859738
Hi brokeMyLegBiking,

Hit F2 then search for EventReasonEnum

Tim Cottee
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 150 total points
ID: 10859744
brokeMyLegBiking,

Looks like adRsnUndoAddNew = 5


Tim.
0
 
LVL 2

Assisted Solution

by:DANNYMAC
DANNYMAC earned 100 total points
ID: 10860835
To better explain what is happening thake a look at this example.

First add a command button that will call a sub as I have done below.  I used a sample table I had built for another example but simply address you ADODC4 and call a addnew, edit some fields and then cancel the update.
Both the addnew and the cancelupdate will cause the event to fire.  The first tiem it will be adreason=1 ( AdReasonAddNew).

Private Sub cmsAddnew_Click()
With Adodc4.Recordset
    .AddNew

    !Title = "Title10"
    !movieno = 10

    .CancelUpdate
    End With
   
End Sub

Add this code to your withevents and it should display the message box on the CancelUpdate event.  Also your Case statement will display "undo Addnew"

If adReason = 5 Then
MsgBox "reason canceled update with addnew"
End If

When the cancel update is called it will fire the adodc4 event and adreason will be #5  adRsnUndoAddNew, or Updo the Add New Command

Hope that clears it up.
D

0
 
LVL 4

Author Comment

by:brokeMyLegBiking
ID: 10863949
beautiful!

thanks guys
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…

717 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