|
-
Nov 6th, 2000, 11:07 AM
#1
Thread Starter
Member
PLEASE -- I urgently need help?? -- Isn't there someone can help me with this error??
Hello All,
when I declare a dim on a form in the general area is it default private to the form public to all forms?
when I unload the form, will these dims disappear?
I'm wondering because I created some ADO.recordsets and when I close the form (click on the x) and reopen the form I get an error stating that the recordsets are still open.
I have since put statements to close the ado.recordsets in the form unload but what the hell? How can they be open if I close the form anyways? cause when I reopen the form it has to redeclare the variables doesn't it? or does form1.show only unhides it?
what there like no garbage collection?
Thanks !
Marci Sarwan ([email protected])
-
Nov 6th, 2000, 03:33 PM
#2
Fanatic Member
when I declare a dim on a form in the general area is it default private to the form public to all forms?
It won't be visible to any other form besides the form in which you've declared it (Private to the form).
when I unload the form, will these dims disappear?
Yes
How can they be open if I close the form anyways?
Because the connection isn't only stored in the variable. Since ADO has to open that connection it will create something of a form of the system-global variable (this variable won't vanish until you use the close method of the ADO)
cause when I reopen the form it has to redeclare the variables doesn't it
It does redeclare it, but when ADO tries to connect to the database, it will find the variable it created during the last connection (which wasn't "destroyed" using the close method). It will try to reconnect, but since there can't be more than one connection it will give the error (and you have two connections: the old one, and the one you trying to do at this time)
-
Nov 6th, 2000, 04:30 PM
#3
Hyperactive Member
Use:
Code:
Static MyVariable As String
'or whatever it is.
-
Nov 6th, 2000, 04:31 PM
#4
Don't Declare as Dim...poor standard
If you only want the variable to be available to the current form declare it as Private. If you want the variable available to all forms/procedures in the project declare it as Public or Global. Note Global is being phased out in version 7.
The database stays connected when you can the project coz you have called it into memory, made the connections, also close on project/form unload.
Don't get me onto record locking, MS suck with this one. Sorry just love bitching about that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|