Hello,
I’m trying to set up a database environment in the “Database Script” module. The “Declarations” section does not seem to accept the keyword “Public” in declaring a variable. I’ve tried writing a Class “globalVariables” where vars are declared as “Public”, then linking to that class via a “Use “GlobalVariables”” statement in the “Options” section of the Database Script. This works as the variables are visible in the debugger when the Initialize event of the DBScript fires and I can work with those vars so long as the DBScript is open. However, when the DBScript completes execution and the DB opens to it’s default view, the vars are still displayed in Designer but they have lost their assignments. The DBScript code:
%REM
Database Script Database Script
Created Jan 10, 2017 by Lee Whitney/crc
Description: Comments for Database Script
%END REM
Option Declare
Use “GlobalClasses”
Use “GlobalVariables”
Use “CommonRoutines”
Use “NewObj”
Sub Initialize
Dim session As New notessession
Dim classname As String
Set db=session.currentdatabase
serverName=db.Server
Dim CR As Variant
className=“CommonRoutines”
Set CR=NewObj(className)
Call CR.SetUpDataSourceDB(session,db,dataDB,serverName)
If Not(dataDB.Isopen)Then
MsgBox “Failed to open ““DataDB””.”,32,“Error in DBScript Init event.”
Exit Sub
End If
End Sub
The vars, db, serverName and dataDB are all declared “Public” in the various linked Classes (“Global…”) and the script executes as expected without error. However, any script written in another module “sees” the public vars but they have lost their assignments.
Your ideas are much appreciated.
Lee