Results 1 to 3 of 3

Thread: accessing the database from different modules.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    18

    Post

    Everytime I add a new form to my project and want to access a database, I have to declare it, and open it.

    Dim db as database
    db.opendatabase("..path..")

    Is there any way I dont have to declare it in every form ?

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Posts
    232

    Post

    Use the Public statement to declare the db variable in the module section. Add new module to your project and place

    Public db As Database

    Variables declared using the Public statement are available to all procedures in all modules. You can open a database in any form.

    ------------------
    smalig
    [email protected]
    http://vbcode.webhostme.com/


  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Post

    You also can open that database and recordset at the main form load event, so that you no need to open/close you database on each form you have created.

    ------------------
    A free Man Stand on a free land.
    [email protected]

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