DSCEventInfo Object

Microsoft Office Web Components Visual Basic

DSCEventInfo Object

DSCEventInfo Multiple objects

Contains information about the specified data source control event.

Using the DSCEventInfo Object

The following data source control events use a DSCEventInfo object as their only parameter:

You can use the properties of the DSCEventInfo object to return information about the data access page when an event is trapped. The Section property can be used to determine the section of the data access page where the event occurred. You can use the ReturnValue property to cancel the completion of some events.

The events listed above vary in their support of the DSCEventInfo properties. Some of the events support a subset of the DSCEventInfo properties, and some events don't support any of the DSCEventInfo properties. Using an unsupported property will result in a run-time error.

The following example cancels the deletion of a record if the Discontinued field is set the No. The Section property of the DSCEventInfo object is used to drill down to the value of the Discontinued field. If the field contains the value No, then the ReturnValue of the DSCEventInfo object is set to False, canceling the deletion of the record.

Sub MSODSC_BeforeDelete(DSCEventInfo)

   Dim txtDiscontinued

   ' Set a variable to the text box that contains the value
   ' of the Discontinued field for the record that is to be deleted.
   Set txtDiscontinued = DSCEventInfo.Section.HTMLContainer _
                        .Children("Discontinued")

   ' Check the value of the control.
   If txtDiscontinued.Value = "No" Then

      ' Display a message to the user.
      Msgbox "Do not delete products that have not " & _
             "been discontinued."

      Cancel the deletion of the record.
      DSCEventInfo.ReturnValue = False
   End If

End Sub