Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global Database Connection?

Status
Not open for further replies.

bmoremu

Programmer
Dec 22, 2003
38
US
I have a workbook with forms that interact with an Access DB. I want to just connect to the DB on Workbook-Open and close the connection when the workbook closes so I won't have to keep opening and closing the connection repeatedly. I tried "Global DB as DAO.Database" but it won't let me do that. How can I connect to the database on Workbook-Open and be able to access the DB variable through the forms/mods? Thanks.
 
Hi,

Declare all your DAO database odjects as Public in a Module.

Then Open the Database in the Workbook Open event and close the database in the workbook close event. Your database objects will be exposed to all modules, Userforms, Worksheets and Workbook objects.

:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top