no current record after delete

G

Guest

I have used the "wizard" to delete a record (from a sub form as it happens)
however after the delete I get the error message "no current record" .

Could you tell me why this is happening and how to prevent it?

The code (which I think is just Access standard) is this:

Private Sub DeleteRequest_Click()
On Error GoTo Err_DeleteRequest_Click

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70


Exit_DeleteRequest_Click:
Exit Sub

Err_DeleteRequest_Click:
MsgBox Err.Description
Resume Exit_DeleteRequest_Click

End Sub

Many thanks

HelenJ
 
A

Allen Browne

Helen, if this is Access 2002 with Service Pack 3 applied, it is a known
bug.

SP3 broke A2002 in this way. It is quite safe to just change your error
handler to ignore this bug, i.e.:
Err_DeleteRequest_Click:
If Err.Number <> xxxx Then
MsgBox Err.Number & " - " & Err.Description
End If
Resume Exit_DeleteRequest_Click
End Sub

where xxxx is the error number you are seeing.
 
G

Guest

Many thanks Allen - it is indeed 2002

Allen Browne said:
Helen, if this is Access 2002 with Service Pack 3 applied, it is a known
bug.

SP3 broke A2002 in this way. It is quite safe to just change your error
handler to ignore this bug, i.e.:
Err_DeleteRequest_Click:
If Err.Number <> xxxx Then
MsgBox Err.Number & " - " & Err.Description
End If
Resume Exit_DeleteRequest_Click
End Sub

where xxxx is the error number you are seeing.
 
G

Guest

Allen,

I am having this problem too: no current record after delete. Where does
your recomended code should be placed? Error Handler? I traced my program
and the error displays right after the Form's error event executes (at the
end sub of form's error even.

Can you tell me how to get rid of this error message?
 
T

tina

from Helen's posted code, it looks like she's using a procedure on the Click
event of a command button called DeleteRequest, to delete records; the
revised error handling code that Allen posted would go in that procedure.

hth
 
G

Guest

Tina,

Thank you for your response.

To share, I am including my solution to this. The code that solved it of me
is below. My tracing of the program shows that this error displays before
the command's button code execute, that is before the sub's error handler can
be set.

Thanks again.


Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr <> 3021 Then ' Error 3021 = " No current record"
Response = acDataErrDisplay
Else ' Error 3021 = " No current record"; Access 2002 has a bug on this
type of error (It should only execute sub's error handler but it doesn't).
Response = acDataErrContinue ' Ignore this error, but make sure you
have error handler in offending sub routing.
End If
 

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

Top