Link to home
Start Free TrialLog in
Avatar of csindorf
csindorf

asked on

globaly used

I have a project with just a few forms on it and on each form I have to have:

Option Explicit
'declare database variables
Public db As Database
Public rs As Recordset

Then on each form in their onload I have to add:

Private Sub Form_Load()

    'open database
    Set db = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\tenneco.mdb")
    Set rs = db.OpenRecordset("select PCID from parts")

End Sub

Is there a simple way through a module I can set these and be able to use them on the other forms without needing to add them to each form??

Craig
ASKER CERTIFIED SOLUTION
Avatar of jgravelle
jgravelle

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dalin
Dalin

You can add a module, put theese delaration in the general declaration area, then goto your project's property, change the startup item to Sub main.  In for submain, add the open database code.  then show your first form.
opps