• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 590
  • Last Modified:

what is adReason = 5 in ADODC_WillChangeRecord?

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
brokeMyLegBiking
Asked:
brokeMyLegBiking
  • 2
2 Solutions
 
TimCotteeCommented:
Hi brokeMyLegBiking,

Hit F2 then search for EventReasonEnum

Tim Cottee
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
TimCotteeCommented:
brokeMyLegBiking,

Looks like adRsnUndoAddNew = 5


Tim.
0
 
DANNYMACCommented:
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
 
brokeMyLegBikingAuthor Commented:
beautiful!

thanks guys
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now