run time error 3021

G

Guest

Good day,

I have created a button in a form to delete records. I am using the
following code:

Private Sub DeleteRecord_click()
if me.Dirty then
me.undo
end if
if not me.newrecord then
runcommand acCmdDeleteRecord
end if
end sub

The problem is when i click the button, it will delete the record but an
error message always shows "Run time error 3021: No current record". Any
ideas?

Regards
mat
 
A

Allen Browne

Mat, is this Access 2002 (Office XP), Service Pack 3?

There's a bug in that service pack that gives this spurious message. There's
no fix, but it's harmless enough, so just add error handling and ignore
error 3021.
 
G

Guest

It is indeed that version of Access. However, i am somewhat of a novice with
access and can't get error handling to work. I have taken a look at your
website and seen an example of script; could you maybe clarify it?

Regards
Mat
 
A

Allen Browne

Private Sub DeleteRecord_click()
On Error Goto Err_Handler:

if me.Dirty then
me.undo
end if
if not me.newrecord then
runcommand acCmdDeleteRecord
end if

Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 3021 Then
MsgBox "Error " & Err.Number & ": " & Err.Description
End If
Resume Exit_Handler
end sub
 
G

Guest

Unfortunately, this doesn't seem to solve the problem. The debbuger points to
the runcommand acCmdDeleteRecord part of the script (=233).
 
A

Allen Browne

Where are you typing this?
Into the code window in Access?

If so, something else is wrong.
From the code window, choose Options on the Tools menu.
On the General tab, make sure you have Error Trapping set to:
Break on Unhandled Errors

Presumably you have already checked that your code compiles, by choosing
Compile on the Debug menu.
 
G

Guest

Hello

is this still a bug in 2003?

my situation is like this:

i have a main form that lists all my issues in a list box. when you double
click on the issue in the list box it opens a form showing an individual
"Issue". this form then has a button which allows the user to view and print
a report based on the "Issue" form.

i have the button looking back at the mainforms list box for the record id,
it works. i have had the button looking to the issueID on the issue form and
that worked. the problem is that on some issues it gives the error "no
current record". after it does this and i try to view the report for one that
did work it gives the error "reserved error".

i have been trying to see if the records were a problem, checking and
rechecking queries, and even filling in empty fields in the records of the
issues.

i had the report opening code using both just the list box and the .column()
with the appropriate number in the brackets. both seem to work for the "good"
records and break on the "bad" records.

any suggestions?
 

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