Error AddData BoundRow Event Handler

The code example in Listing 7.32 displays a message if the date field of a data-bound row is left blank. The code that created the list object specified that the date column must not contain a null value, which causes the error.

Listing 7.32. Capturing an error when a data-bound row cannot be added to a list object

Private Sub List1_ErrorAddDataBoundRow(ByVal sender As Object, _ ByVal e As Microsoft.Office.Tools.Excel. _ ErrorAddDataBoundRowEventArgs) Handles _ List1.ErrorAddDataBoundRow

Dim currentRange As Excel.Range = Me.Application.Selection

If CType(currentRange.Columns(1), Excel.Range).Value _ Is Nothing Then

MsgBox("Date cannot be empty.")

End If

End Sub

0 0

Post a comment