Results 1 to 4 of 4

Thread: Weird Error message???

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    Posts
    52

    Unhappy 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 (marci_sarwan@yahoo.com)

    Marci Sarwan

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    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)

  3. #3
    Hyperactive Member Asaf_99's Avatar
    Join Date
    Jul 2000
    Location
    Israel
    Posts
    335
    Use:
    Code:
    Static MyVariable As String
    'or whatever it is.
    Asaf Sagi

    ICQ: 61917199
    E-Mail: sagiasaf@netvision.net.il

  4. #4
    Guest

    Thumbs up 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
  •  



Click Here to Expand Forum to Full Width