Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Location
    Birmingham, UK
    Posts
    19

    Question Unanswered: Private module variables?

    I have a database that has been converted from 97 to 2k3. There is now a problem in the database in that a recordset is closed at the wrong point of time

    I know the line that causes the problem i just dont see how it is doing it?!!!

    There are two modules both with private recordset and database variables with the same names

    These variables are in use in mod1 when it calls methods in mod2 that use the varaibles declared in that module.

    Eventulaly the mod2 method closes and sets to nothing the database variable, this causes the recordset variable in mod1 to close and so the code errors when excecution returns to the mod1 method

    Both modules use
    set db=workspace(0).database(0)

    is this the cause of the problem of private module variables getting closed in the wrong place? i.e. both database variables are seperate but acctualy refference the same database object?

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    It shouldn't matter. Assuming you're using DAO recordsets, since you converted from 97, each recordset you instantiate is it's own object and independent of all others. could you post the code you're using to instantiate and release your objects from both mods?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jun 2004
    Location
    Birmingham, UK
    Posts
    19
    code is in the attached, its a bit scrappy but important bits are there

    The solution seems to be to explicity define the db and rq varaibles as DAO.Recoredset/Database and use
    set db=currentdb()

    exactly why this solves the problem im not sure, any ideas/explainations?
    Attached Files Attached Files

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I didn't download the code, but yeah, that's exactly what I was looking for.

    By default, 97 uses DAO for data manipulation where as 2000 and higher default to ADO. Therefore, when you implicitly define a dataset like so:

    Dim myRs As Recordset

    it means two different things. In 97, it means DAO.Recordset. In 2000+, it means ADODB.Recordset.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •