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!

Declare a public value for a public var

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,

I have a database 5Mb size.
I am thinking that maybe it would be better for development reasons (continuous improvements to come while in use), to split the database, back end and front end.
I used a lot of recordsets, and therefore the following statement:

Set recordset= currentdb.openrecordset(....)

The problem is that now the currentdb is not valid anymore, and I want to substitute this statement by:

Set recordset= backdb.openrecordset(...)

where, at opening the database I declared backdb as "c:\access\database_be.mdb"

I tried:
set backdb ="c:\access\database_be.mdb"
when opening a form, just to try, but it does not accept it (ambiguous)

Thanks,

AmaHerrn
 
Try this:

'Declare a workspace variable
Public wsp as DAO.Workspace
Public dbs as DAO.Database

Set wsp = DBEngine.Workspaces(0)
Set dbs = wsp.OpenDatabase("c:\access\database_be.mdb")


'I use this structure to export Access Objects from an emailed Update mdb to the application mdb on the users computer. It works like a charm.

Hope that helps.

Bob
 
Sorry, I think I did not explain myself correctly.

I was looking for something like...

Public Const backdb As Object = OpenDatabase("c:\access\database_be.mdb")

...to be entered in a module where I have all variables declared.

So, instead of having to add this line in every class module, i.e., in every form, I would like to declare it only on one place, if possible in the module where I declare all vars.

In any case, thanks for the answer.

AmaHerrn
 
Place your 'Const' in a module created by selecting a new module from the module tab. Use the Public keyword for the Const statement. All public Constructs, subs and functions placed in a module become available to all forms within the database.

mac
 
In a standard module you could place a public variable for the database in the General Declarations then in the mdb's autoexec set the variable to to the workspace by running a routine like the one that I wrote. You only have to run it once and it can be called by anywhere in application for as long as the application is open.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top