Connection

  • Thread starter Thread starter Ruben Granados
  • Start date Start date
R

Ruben Granados

Hi, is there a way to detemine if a connection is opened?
In a click event of a command button I open 3 recordset.
if an error occurs in the first then the code jumps to the
error handling. but the error handling cycles because
there I'm closing recordsets that maybe weren't open in
the time the error occured.

thx.
 
I'm just guessing on how you may have the code... I suspect that you have
the Recordset Close method at the end of your procedure?

May I recommend something like the following (see below).

With the "On Error Resume Next", if your code jumps to the error handler
before the other recordsets are open, the error handler won't flag the
remaining recordsets as issues.

Public Sub ABC123()

On Error Goto Proc_Err

Proc_Exit:

On Error Resume Next
Rst1.Close
Set Rst1 = Nothing

Rst2.Close
Set Rst2 = Nothing

Exit Sub

Proc_Err:
Resume Proc_Exit

End Sub


HTH

--
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
Ruben Granados said:
Hi, is there a way to detemine if a connection is opened?
In a click event of a command button I open 3 recordset.
if an error occurs in the first then the code jumps to the
error handling. but the error handling cycles because
there I'm closing recordsets that maybe weren't open in
the time the error occured.

thx.


Connection.State will tell you if a connecton is open or not.
 
Back
Top