"No Current Record" on "DoCmd.RunCommand acCmdDeleteRecord"

Gezza

Registered User.
Local time
Today, 22:20
Joined
Jun 19, 2009
Messages
53
Hi
I am getting the "No Current Record" on the "DoCmd.RunCommand acCmdDeleteRecord" when I run it the first time, when I run it again it runs without the error message?

This is run just before a Close form CMD

Hope someone can help

Cheers
Gezza
 
Please post your code and highlight where it crashes.

What is a CMD
 
Yes Win7 & Access 2003
 
If that reply is the best you can do then I can't help. :banghead:

Did you read my post at all.? :banghead:
 
Sorry RainLover, got to many things happening.

This is the code, error comes up from the "DoCmd.RunCommand acCmdDeleteRecord" Line
CMD is short for "command"

DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Echo False
DoCmd.Close acForm, "frm_Action"
DoCmd.Echo True

Gezza
 
I need all the code so I can see exactly what is going on. From Sub to End Sub.

But here is some advice. Don't use code that you don't know what it does.

e.g.

DoCmd.SetWarnings False
DoCmd.Echo False
DoCmd.Echo True

I suggest that unless you fully understand these and know the ramifications then I suggest you Rem them out.
 
Here is all the code, I have taken your suggestion and removed unnecessary code, "I inherited the database".
Error is still occurring

Private Sub btn_ClosefrmAction_Click()
On Error GoTo Err_btn_ClosefrmAction_Click

Dim DelAction As Integer

DelAction = MsgBox("If you EXIT from this view you will Delete this Action record, 'DO YOU WISH TO CONTINUE'", vbYesNo)

If DelAction = vbYes Then

txb_TickHoldasActioned.Value = 0
lbl_ActionDetail.Visible = False
cmb_ActionDetail.Visible = False
lbl_EstRepairTime.Visible = False
txb_Repair_Time.Visible = False
lbl_PartailScrap.Visible = False
txb_PartialScrap_Length.Visible = False
lbl_RemakeReqYes.Visible = False
chk_RemakeReqYes.Visible = False
lbl_RemakeReqNo.Visible = False
chk_RemakeReqNo.Visible = False
lbl_Scrap.Visible = False
lbl_MgtApproval.Visible = False
lbl_Release.Visible = False

DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
DoCmd.Close acForm, "frm_Action"
Else
Exit Sub
End If

Exit_btn_ClosefrmAction_Click:
Exit Sub

Err_btn_ClosefrmAction_Click:
MsgBox Err.Description
Resume Exit_btn_ClosefrmAction_Click

End Sub
 
Give this a try.

Here is all the code, I have taken your suggestion and removed unnecessary code, "I inherited the database".
Error is still occurring

Private Sub btn_ClosefrmAction_Click()
On Error GoTo Err_btn_ClosefrmAction_Click

Dim DelAction As Integer

DelAction = MsgBox("If you EXIT from this view you will Delete this Action record, 'DO YOU WISH TO CONTINUE'", vbYesNo)

If DelAction = vbYes Then

Me.Undo

txb_TickHoldasActioned.Value = 0
lbl_ActionDetail.Visible = False
cmb_ActionDetail.Visible = False
lbl_EstRepairTime.Visible = False
txb_Repair_Time.Visible = False
lbl_PartailScrap.Visible = False
txb_PartialScrap_Length.Visible = False
lbl_RemakeReqYes.Visible = False
chk_RemakeReqYes.Visible = False
lbl_RemakeReqNo.Visible = False
chk_RemakeReqNo.Visible = False
lbl_Scrap.Visible = False
lbl_MgtApproval.Visible = False
lbl_Release.Visible = False

DoCmd.Close acForm, "frm_Action"
Else
DELETED
End If

Exit_btn_ClosefrmAction_Click:
Exit Sub

Err_btn_ClosefrmAction_Click:
MsgBox Err.Description
Resume Exit_btn_ClosefrmAction_Click

End Sub

Have a go at this and if it doesn't work then post back.
 
Thanks again for your response, sorry I've taken so long to reply, (no excuses).

That code stopped the error from occurring but did not delete the record.
The "DoCmd.RunCommand acCmdDeleteRecord" does delete the record before I get the error message. Will keep persevering and will post if I find a solution.

Again thank you for your help so far
Gezza
 

Users who are viewing this thread

Back
Top Bottom