View Single Post
  #6  
Old August 18th, 2004, 07:31 PM
Dan Artuso
external usenet poster
 
Posts: n/a
Default

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?

Dan Artuso, MVP

"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

[...]