View Single Post
  #12  
Old August 19th, 2004, 11:22 AM
Brendan Reynolds
external usenet poster
 
Posts: n/a
Default

I wouldn't usually do this, but curiosity got the better of me, and I took a
look at the MDB you posted. I noticed that the error doesn't occur if I
open and close the form without clicking the command button. It occurs only
after clicking the button, the code behind which writes a record to a table
and then deletes that same record. This leads me to suspect that we're
seeing some kind of timing or caching problem. If this were DAO, I'd be
thinking about putting in a couple of DbEngine.Idle statements, one after
the line that writes the record and another after the line that deletes it.
But I don't know what, if anything, the ADO equivalent of DbEngine.Idle
might be?

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


"Boris" wrote in message
...
Dan Artuso wrote:
Hi,
Okay, 3021 is "no current record".
I'm still not understanding why you are testing for Nothing?
I mean, even if there are no records the form will still have a
recordset, no?
It will just not contain any records.

What is the purpose of the Is Nothing check?
Can you just trap for 3021 and ignore it?


Yes, I could just ignore 3021. However I try to understand where this
runtime error comes from as it might be caused because of other problems -

I
don't know. As I can reproduce this runtime error I try to find the reason
for it.

In my test database the "Is Nothing" check is of no use of course. However
this check causes runtime error 3021 somehow when the form is closed. The
"Is Nothing" check shouldn't do anything, should it? When I comment this
check I don't get any runtime error any more.

The code I sent in my first posting is just the stripped down version of

my
production database. In my production database there is of course much

more
going on in Form_Current(). I have to check the Recordset for Nothing in

my
production database as the subform's Recordset is set dynamically by the
embedding form. And as subforms are loaded first the code in

Form_Current()
must not be executed until the embedding form has set the subform's
Recordset.

However all that really doesn't matter as a check for "Me.Recordset Is
Nothing" shouldn't cause runtime error 3021 when the subform is closed?

Before I try even more to explain I attach the test database in a zip file
to this posting. When you open the database the main form is started
automatically. Click on the button and then close the main form - I get
runtime error 3021 then. When you remove the "Recordset Is Nothing" check
the runtime error disappears. If I know that this is a bug in Access I

will
just ignore 3021. However I would appreciate a confirmation of this bug as
otherwise my code could be wrong of course, too.

Thanks for your help by the way! :-)

Boris

"Boris" wrote in message
...
Dan Artuso wrote:
Hi,
Is Nothing is used to see if an Object variable is 'Set' or not.
It's not used to see if a recordset is empty or not.
I usually use it like this:

ExitHe
If Not rs Is Nothing Then
Set rs = Nothing
End If

To see if your recordset is empty, get the record count if possible,
or check the EOF and BOF properties.

Thanks for your answer. However that's not the problem. The
production database uses code likes this:

If Not Me.Recordset Is Nothing Then
If Not (Me.Recordset.BOF Or Me.Recordset.EOF) Then
...
End If
End If

Checking for empty recordsets works without any problems. The
problem is that it causes a runtime error 3021 when you close the
main form. I stripped the code as much as possible for my test
database to track the bug. For runtime error 3021 it just matters
that you test "Me.RecordSet Is Nothing". I don't do anything else in
Form_Current() in my test database but still get runtime error 3021.
If I comment the if-then-clause the runtime error strangely
disappears?

Boris

[...]