?
Solved

what is adReason = 5 in ADODC_WillChangeRecord?

Posted on 2004-04-19
4
Medium Priority
?
585 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 600 total points
ID: 10859744
brokeMyLegBiking,

Looks like adRsnUndoAddNew = 5


Tim.
0
 
LVL 2

Assisted Solution

by:DANNYMAC
DANNYMAC earned 400 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

Industry Leaders: 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!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code 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…
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…
Suggested Courses

649 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