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).Ope nDatabase( 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
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).Ope
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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