Database Record Deleting

Robert Allan

New Member
Joined
Mar 30, 2020
Messages
19
Office Version
  1. 365
Platform
  1. Windows
I am creating a Data Entry Form in Excel and I am having a problem deleting a record. My Subs Save, Modify and Reset are all working fine, but I keep getting the Runtime error 1004 “method of range class failed”. The following is my sub-routine:
VBA Code:
Sub DeleteRecord()
    Dim iRow As Long
    Dim iRec As Long
           iRec = Application.InputBox("Please enter Rec No. to delete the record.", "Delete Record?", , , , , , 1)
                    If iRow = 2 then
                         iRec = 1
                   End If
    On Error Resume Next
    iRow = Application.WorksheetFunction.IfError(Application.WorksheetFunction.Match(iRec, Sheets("Data 2020").Range("A:A"), 0), 0)
               On Error GoTo 0
                If iRow = 0 Then
                    MsgBox "No record found", vbOKOnly + vbCritical, "No Record"
                 Exit Sub
              End If
    Sheets("Data 2020").Cells(iRow, 1).EntireRow.Delete shift:=xlUp
End Sub

Please Help!
 
Last edited by a moderator:
Glad you got it sorted. Thanks for letting us know (in the right place. ;))
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,214,982
Messages
6,122,573
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top