"No Current Record" Warning

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

When I click this delete button I am getting this Microsoft access Error
"No Current Record" even if there is data in it!!
Thanks in advance.........Bob Vance
 
When I click this delete button I am getting this Microsoft access Error
"No Current Record" even if there is data in it!!
Thanks in advance.........Bob Vance

Please post the code being executed by the delete button.

John W. Vinson[MVP]
 
Thanks John,
OnClick:
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.RunCommand acCmdRecordsGoToPrevious
DoCmd.SetWarnings True
're-calculate totals and sub-totals

If Me.Parent.Name = "frmInvoice" Then
Forms!frmInvoice.SubCalculate
Else
Forms!frmInvoiceClient.SubCalculate
End If
' SubCalculate
Exit_cmdDelete_Click:
Exit Sub
 
Yet the Black Arrow in the Grey Box and delete button work on the key board
.....Thanks Bob
 
Thanks John,
OnClick:
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.RunCommand acCmdRecordsGoToPrevious
DoCmd.SetWarnings True
're-calculate totals and sub-totals

I'd say Allen's got it: if you select the first record, or delete the
only record in the recordset, the GoToPrevious will trigger this
error. What line is highlighted when the error occurs?

John W. Vinson[MVP]
 
John Vinson said:
I'd say Allen's got it: if you select the first record, or delete the
only record in the recordset, the GoToPrevious will trigger this
error. What line is highlighted when the error occurs?

John W. Vinson[MVP]

OK, I am only getting the warning now when it is the last line to delete if
there is 4 lines I can delete line3,2,1 but the last line left or the very
bottom line are giving me the error........Thanks Bob
 
Bob, what version of Access is this?

This bug is a known issue in Access 2002 Service Pack 3.
If you are using this version, use your error handler to ignore the error.

If you are not using that version, a better delete routine might be:
If Me.Dirty Then
Me.Undo
End If
If Not Me.NewRecord Then
RunCommand acCmdDeleteRecord
End If
 
Yes Allen 2002 SP3!

Allen Browne said:
Bob, what version of Access is this?

This bug is a known issue in Access 2002 Service Pack 3.
If you are using this version, use your error handler to ignore the error.

If you are not using that version, a better delete routine might be:
If Me.Dirty Then
Me.Undo
End If
If Not Me.NewRecord Then
RunCommand acCmdDeleteRecord
End If
 
This worked but not the last line or the last line left after deleting
Run Time Error "3021":
No Current Record
 
I would not have expected the error on this line, unless there is no record,
of course.
 
Allen how do I do this: If you are using this version, use your error
handler to ignore the
error. thanks Bob
 
Changed it to this and it seems to work:
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click


DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord


Exit_cmdDelete_Click:
Exit Sub

Err_cmdDelete_Click:

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top