Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dim in general decl section (Access)

    I would like to know if it is possible to have

    dim dbs as adodb.connection

    in the general declaration section of the program.

    I have been using it for a while and everything has been fine till now. The program forces me to have this statement in the beginning of each sub that use dbs.

    Thanks

  2. #2
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dim in general decl section (Access)

    It depends where you have declared this variable.

    If you have put this in a class module (ie. a module belonging to a form or report) then the varaible is only going to be available to other proceedures within that module.

    If you put it in a standard module - then it should be available to all proceedures in the project.

    J

  3. #3
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dim in general decl section (Access)

    Remember that is it is generally good practice to close and set all object variables to nothing after using them

    dbs.close
    set dbs = nothing

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: dim in general decl section (Access)

    Anything declared in the general declarations area of an object (form, report , or module) should be available to all subs and functions within that object. I can't imagine why you would be having such problems, unless there was a duplicate. I'd take out all the declarations for dbs in the module except for the one in general area to see what happened. Another possibility, if the situation you were describing was in a form, and there was a dbs defined in a module as Public, it might cause problems.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dim in general decl section (Access)

    I think that the important part of your statement is "within that object" (especially for forms and reports).

  6. #6
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dim in general decl section (Access)

    Apparently there is a report which is corrupted and it causes all the grief. I have to create a new database and import all the objects (except that specific report) and then everything works fine. If I import that corrupted report, not only the report will not work, it cause the so called "network error" and the entire database will have problem in compiling.

    Thanks for all the insights.

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: dim in general decl section (Access)

    I just posted a response to that problem in this thread. You might want to take a look at it.
    Charlotte

Posting Permissions

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