A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Scope of Database Definition



 
 
Thread Tools Display Modes
  #1  
Old December 6th, 2007, 05:55 PM posted to microsoft.public.access.tablesdbdesign
cmdex_VABCH via AccessMonster.com
external usenet poster
 
Posts: 2
Default Scope of Database Definition

I have an older database I am now responsible for. It appears that the
original programmer set a global database definition at startup and wanted to
use it through out the program when ever he needed it. Well the database has
been worked and reworked so many times that the single database definition
just isn't used anymore except on occassion in the original code.

Example:
~At startup in called Module M:
dim GblDb as Database
~module M, function F:
set GblDb = CurrentDb()
~form X:
set y = GblDb.OpenRecordset(.....
~module Z:
set b = GblDb.OpenRecorset(......
set GblDb = Nothing
~form A:
set c = GblDb.OpenRecorset(....

My question is, does a single definition used through out the program have
any significant advantages, other than not having to define a db definition
for each function? When does the global definition lose scope?

I should mention that the database is a front end, with an Oracle back end,
and resides on a server with as many as 50 concurrent users.

Some insight would be helpful. Thank you.

--
Message posted via http://www.accessmonster.com

  #2  
Old December 7th, 2007, 01:36 AM posted to microsoft.public.access.tablesdbdesign
Allen Browne
external usenet poster
 
Posts: 11,706
Default Scope of Database Definition

In the early days of Access, some developers used globals because:
a) It saved them having the declare the variable repeatedly in many
functions.

b) They perceived a performance advantage if the variable is already set.

c) It used less resources to keep reusing the same database variable.

IMHO, these advantages are outweighed by other considerations, such as:
a) The variable gets destroyed when you Reset during debugging.
So you must test it and reinitialize when needed.

b) The maintenance nightmare of a global, where any piece of code could
point it to the wrong thing (especially as the database grows, or with
multiple developers.)

c) Scope confusion, since VBA also permits a local variable to have the same
name.

d) The 'performance' and 'resource' issues are bogus, since:
- Machines are faster and have more RAM.
- You can use dbEngine(0)(0) to point to an existing object if you care.
- You can pass a db object from one routine to another where it matters.

Hopefully each of your users has their own distinct copy of the front end
(not all 50 people using the same MDB file.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"cmdex_VABCH via AccessMonster.com" u39420@uwe wrote in message
news:7c4ab6fe82454@uwe...
I have an older database I am now responsible for. It appears that the
original programmer set a global database definition at startup and wanted
to
use it through out the program when ever he needed it. Well the database
has
been worked and reworked so many times that the single database definition
just isn't used anymore except on occassion in the original code.

Example:
~At startup in called Module M:
dim GblDb as Database
~module M, function F:
set GblDb = CurrentDb()
~form X:
set y = GblDb.OpenRecordset(.....
~module Z:
set b = GblDb.OpenRecorset(......
set GblDb = Nothing
~form A:
set c = GblDb.OpenRecorset(....

My question is, does a single definition used through out the program have
any significant advantages, other than not having to define a db
definition
for each function? When does the global definition lose scope?

I should mention that the database is a front end, with an Oracle back
end,
and resides on a server with as many as 50 concurrent users.

Some insight would be helpful. Thank you.


  #3  
Old December 12th, 2007, 08:58 PM posted to microsoft.public.access.tablesdbdesign
cmdex_VABCH via AccessMonster.com
external usenet poster
 
Posts: 2
Default Scope of Database Definition

Mr. Browne,
Thank you for the insight. I have been to your site many times and
appreciate all the help you have proveded through the years.

And no, I have seen as many as 15 concurrent users in the same database (MDE)
on the server at the same time. It's the way this company solved the
distribution to each user issue. Trust me, I am working to correct that as
soon as possible.

Thank you again!

Allen Browne wrote:
In the early days of Access, some developers used globals because:
a) It saved them having the declare the variable repeatedly in many
functions.

b) They perceived a performance advantage if the variable is already set.

c) It used less resources to keep reusing the same database variable.

IMHO, these advantages are outweighed by other considerations, such as:
a) The variable gets destroyed when you Reset during debugging.
So you must test it and reinitialize when needed.

b) The maintenance nightmare of a global, where any piece of code could
point it to the wrong thing (especially as the database grows, or with
multiple developers.)

c) Scope confusion, since VBA also permits a local variable to have the same
name.

d) The 'performance' and 'resource' issues are bogus, since:
- Machines are faster and have more RAM.
- You can use dbEngine(0)(0) to point to an existing object if you care.
- You can pass a db object from one routine to another where it matters.

Hopefully each of your users has their own distinct copy of the front end
(not all 50 people using the same MDB file.)


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...esign/200712/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:06 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.