Here's what I came up with - not sure that it's fully tested, but it hasn't bombed when I've deleted any/all of the records in the table.
Code:
Sub DeleteRecord()
'don't let the user issue a delete command if in add mode
If blnAddMode = True Or rsContacts.RecordCount = 0 Then
Exit Sub
End If
Dim intResponse As Integer
'confirm that user really wants to delete record
intResponse = MsgBox("Are you sure you want to delete this record?", vbYesNo)
'if the user cancels delete, then exit this procedure
If intResponse = vbNo Then
Exit Sub
End If
'declare and create new command object
Dim cmdCommand As ADODB.Command
Set cmdCommand = New ADODB.Command
'create a new connection instance and open it using the connection string
Set cnCh5 = New ADODB.Connection
cnCh5.Open strConnection
'declare variable to store current contact
Dim intCurContact As Integer
intCurContact = 0
'generate SQL command to delete current record
Dim strSQL As String
strSQL = "DELETE FROM tblContacts WHERE intContactId = " & rsContacts!intContactId
'set the command to the current connection
Set cmdCommand.ActiveConnection = cnCh5
'set the delete SQL statement to the command text
cmdCommand.CommandText = strSQL
'execute the delete command against the database
cmdCommand.Execute
'move to the previous record in the local recordset since the
'current one is being deleted
If rsContacts.RecordCount > 1 Then
If Not rsContacts.BOF Then
rsContacts.MovePrevious
If rsContacts.BOF Then
rsContacts.MoveFirst
rsContacts.MoveNext
End If
'save the id of the current (previous) record
intCurContact = rsContacts!intContactId
End If
End If
'while connected to the database, go ahead and
'repopulate the recordset to make sure it contains
'the most current values from the database.
Set rsContacts.ActiveConnection = cnCh5
rsContacts.Requery
Set rsContacts.ActiveConnection = Nothing
If intCurContact <> 0 Then
'move back to the contact that was current before the
'requery
rsContacts.Find "[intContactId] = " & intCurContact
'populate the controls on the form
Call PopulateControlsOnForm
Else
Call ClearControlsOnForm
End If
End Sub