Solved

what is adReason = 5 in ADODC_WillChangeRecord?

Posted on 2004-04-19
4
578 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

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 I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 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