Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lifespan of a Connection Object

Status
Not open for further replies.

rpbenito

Programmer
Jun 13, 2001
63
US
Is it possible to use a sub procedure to set the connection and the use that connection somewhere else in the code? Every time i set the connection in the procedure everyrthing works fine, but the minute I try to reference the connection or return it using a function I get the error "Object invalid or no longer set". Is there a way to establish a connection and the be able to use that connection outside the sub funtion or procedure? Thanks
 
Just have the

Dim oCnn as new ADODB.Connection

part outside of the function/sub (as a declaration).

If it's got to be accessible from other modules,

make it a class module and instantiate it where needed. codestorm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top