Private Sub CMDEL_Click()
'On Error GoTo ErrorHandler
Dim sql As String
Dim rs As DAO.Recordset
Dim ActID As Long
ActID = Me.OccupantID.value
sql = "SELECT * FROM RoomOccupations WHERE ([OccupantID] = " & ActID & ""
Set rs = CurrentDb.OpenRecordset(sql)
With rs
If Not .BOF And Not .EOF Then
.MoveLast
.MoveFirst
If .Updatable Then
.Delete
End If
End If
.Close
End With
ExitSub:
Set rs = Nothing
'...and set it to nothing
Exit Sub
'ErrorHandler:
'Resume ExitSub
End Sub
'On Error GoTo ErrorHandler
Dim sql As String
Dim rs As DAO.Recordset
Dim ActID As Long
ActID = Me.OccupantID.value
sql = "SELECT * FROM RoomOccupations WHERE ([OccupantID] = " & ActID & ""
Set rs = CurrentDb.OpenRecordset(sql)
With rs
If Not .BOF And Not .EOF Then
.MoveLast
.MoveFirst
If .Updatable Then
.Delete
End If
End If
.Close
End With
ExitSub:
Set rs = Nothing
'...and set it to nothing
Exit Sub
'ErrorHandler:
'Resume ExitSub
End Sub