Delete Record

Bagel

Registered User.
Local time
Today, 08:00
Joined
Jun 13, 2003
Messages
15
Hi Again

I have been using the following code to delete records from my database for some time but for some reason this code now gives me the runtime error 3021 - no current record.

It may be wishful thinking but I think it may be a microsoft issue because if I create a new form and copy/paste in all data from old form I don't have this problem:

My code I am using is:


Private Sub Delete_Record_Click()

DoCmd.SetWarnings False

strMessage = "Are you sure you want to delete the Season " & [SeasonName].Column(1) & " "
Style = vbCritical + vbYesNo
strTitle = "Delete Record?"
Response = MsgBox(strMessage, Style, strTitle)

If Response = vbYes Then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.Requery "SeasonName"
SeasonName = Me.SeasonID
Else
Exit Sub
End If
End Sub

The runtime error appears at the "DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70" line

Can anybody help me out with this?
 
Try the following:

Replace
Code:
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
with
Code:
DoCmd.RunCommand acCmdDeleteRecord 
Me.Refresh

I asked the same thing last year!
:)

I'll give you the same advice Mile-O-Phile gave me
"Just be wary of:

DoCmd.DoMenuItem statements...
"
 
Many thanks

Thanks Cosmos75, I will change it all now, thank god for find/replace.

I shall take note of Mile-o-Philes warning, luckily it is the only domenuitem statement I have.
 
Well unfortunatly I am still getting the run time error 3021 - no current record, when I debug it even shows a record number! it seams quite confused, or is that me?

Any ideas?
 

Users who are viewing this thread

Back
Top Bottom