Solved

what is adReason = 5 in ADODC_WillChangeRecord?

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

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

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

746 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

12 Experts available now in Live!

Get 1:1 Help Now