Click to See Complete Forum and Search --> : accessing the database from different modules.
zambian
Feb 20th, 2000, 04:43 PM
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 ?
smalig
Feb 20th, 2000, 06:21 PM
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
smalig@hotmail.com
http://vbcode.webhostme.com/
Chris
Feb 21st, 2000, 12:15 AM
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.:cool:
ccthou@yahoo.com
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.