PDA

Click to See Complete Forum and Search --> : Subs and recordsets


Kagey
Dec 29th, 2000, 07:32 PM
Hello,

I have a problem and i am sure there is a simple solution. When i create a connection and a recordset in the click event of a button, i can't access the recordset's or connections's properties outside of the sub. It just gives me the "object required" msg. I can manipulate them inside of the same sub, but that's it.

Dont ask y i posted this in this forum, cause i dont know

Thanks in advance!

Kyle

[Edited by Kagey on 01-02-2001 at 07:59 PM]

PRIVATE1
Dec 30th, 2000, 09:30 AM
Is your object Variable going out of scope ?


[]P

Kagey
Dec 30th, 2000, 09:46 AM
apparently it is. i created it using

Dim conn as new adodb.connection
Dim rst as new adodb.recordset


when i do this, i can only access their properties inside of the same sub.

Kagey
Dec 30th, 2000, 09:25 PM
Never mind, i figured it out. thanks for your help though. It helped me out (which is why it is called help).

later

Kagey
Dec 31st, 2000, 07:22 PM
in general declarations

Private WithEvents con As ADODB.Connection
Private WithEvents rst As ADODB.Recordset


then in the sub i put


Set con = New ADODB.Connection
Set rst = New ADODB.Recordset


is there a more efficent way of doing it?