Example

Deleting Records.


Delete Selected Records Sub Procedure.

The following is an example of a sub procedure to display a message box with the number of selected records.  The user can choose to delete the records or not.  The code assumes an open recordset and a DGrid control named "DGrid1" sited on the form.


Private Sub DeleteSelectedRecords()
    Dim msg As String
    Dim ret As VbMsgBoxResult
    Dim row1 As Long
    Dim row2 As Long
    Dim numrows As Long
	    
    row1 = DGrid1.SRow
    row2 = DGrid1.SRow2
    numrows = row2 - row1 + 1
    msg = "You are about to permanently delete " _
          & numrows & " records. Do you want to continue?"
    ret = MsgBox(msg, vbYesNo Or vbInformation, "Delete Records")
    If ret = vbYes Then
        'Delete the selected rows
        DGrid1.DeleteRows
    Else
        'Do nothing
    End If
End Sub