"No Current Record" Warning

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
 
J

John Vinson

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]
 
B

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

If Me.Parent.Name = "frmInvoice" Then
Forms!frmInvoice.SubCalculate
Else
Forms!frmInvoiceClient.SubCalculate
End If
' SubCalculate
Exit_cmdDelete_Click:
Exit Sub
 
B

Bob

Yet the Black Arrow in the Grey Box and delete button work on the key board
.....Thanks Bob
 
J

John Vinson

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]
 
B

Bob

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
 
A

Allen Browne

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
 
B

Bob

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
 
B

Bob

This worked but not the last line or the last line left after deleting
Run Time Error "3021":
No Current Record
 
A

Allen Browne

I would not have expected the error on this line, unless there is no record,
of course.
 
B

Bob

Allen how do I do this: If you are using this version, use your error
handler to ignore the
error. thanks Bob
 
B

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

Command Button Question 7
DELETE FROM a table WHERE... 1
Inserting Records! 6
Unused tables and Reports 1
No Current Record 2
Conditional Formating 2
TextBox Question! 7
Dropdown list to open Form help! 1

Top