Assume the following:
1) multi-user environment
2) when user opens app, want to run some code that retrieves some
information specific to the user...retrievi ng this information is
somewhat i/o intensive, so would prefer to retrieve the info once at
the beginning of the session, and have the data persist for the
session
3) several forms in the app need to reference the information
retrieved in #2 (the information specific to the user)
4) would prefer to have a solution where the information specific to
the user (the info retrieved in #2) is NOT stored in a table...instead
the information is stored in a VB data structure, and the VB code is
organized such that:
a) the data structure gets initialized when the user opens the app
b) the information in the data structure persists while the user has
the app open
c ) the data structure is such that the code behind the forms that
need the data have 'visibility' to the data in that data structure
So, my questions are:
1) Is there a 'best practices' way of setting up the VB data structure
to handle the situation described above? If so, what would the
outline of that be for this situation?
2) Is this, perhaps, a good candidate for the use of a class module?
Thank you. 6 2768 mi************@ yahoo.com wrote:
Assume the following:
1) multi-user environment
2) when user opens app, want to run some code that retrieves some
information specific to the user...retrievi ng this information is
somewhat i/o intensive, so would prefer to retrieve the info once at
the beginning of the session, and have the data persist for the
session
3) several forms in the app need to reference the information
retrieved in #2 (the information specific to the user)
4) would prefer to have a solution where the information specific to
the user (the info retrieved in #2) is NOT stored in a table...instead
the information is stored in a VB data structure, and the VB code is
organized such that:
a) the data structure gets initialized when the user opens the app
b) the information in the data structure persists while the user has
the app open
c ) the data structure is such that the code behind the forms that
need the data have 'visibility' to the data in that data structure
So, my questions are:
1) Is there a 'best practices' way of setting up the VB data structure
to handle the situation described above? If so, what would the
outline of that be for this situation?
2) Is this, perhaps, a good candidate for the use of a class module?
Thank you.
Class module or just a hidden form with various controls to hold the values.
You could use global variables but they can lose their values if an unhandled
error occurs (MDB, not MDE). Class objects and hidden forms would not have this
issue.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
On Wed, 5 Dec 2007 17:26:14 -0800 (PST), mi************@ yahoo.com
wrote:
YES! This is perfect for a class module. There is nothing wrong with
declaring a more classic Type and having a global variable reference
it, but an object representing the user is much more elegant and
versatile.
Start your application with an AutoExec macro (rather than a startup
form). It has just one command: RunCode, InitApplication ()
In a standard module write the public function InitApplication , which
as part of its processing (before opening the first form) creates a
global user object of the type referenced in your class module, and
populates it, perhaps by calling an Init method.
Then throughout your app you have access to that object through the
global variable. g_User.FirstNam e, etc.
-Tom.
>Assume the following: 1) multi-user environment 2) when user opens app, want to run some code that retrieves some information specific to the user...retrievi ng this information is somewhat i/o intensive, so would prefer to retrieve the info once at the beginning of the session, and have the data persist for the session 3) several forms in the app need to reference the information retrieved in #2 (the information specific to the user) 4) would prefer to have a solution where the information specific to the user (the info retrieved in #2) is NOT stored in a table...instead the information is stored in a VB data structure, and the VB code is organized such that:
a) the data structure gets initialized when the user opens the app
b) the information in the data structure persists while the user has the app open
c ) the data structure is such that the code behind the forms that need the data have 'visibility' to the data in that data structure
So, my questions are: 1) Is there a 'best practices' way of setting up the VB data structure to handle the situation described above? If so, what would the outline of that be for this situation? 2) Is this, perhaps, a good candidate for the use of a class module?
Thank you.
Tom van Stiphout wrote:
On Wed, 5 Dec 2007 17:26:14 -0800 (PST), mi************@ yahoo.com
wrote:
YES! This is perfect for a class module. There is nothing wrong with
declaring a more classic Type and having a global variable reference
it, but an object representing the user is much more elegant and
versatile.
Start your application with an AutoExec macro (rather than a startup
form). It has just one command: RunCode, InitApplication ()
In a standard module write the public function InitApplication , which
as part of its processing (before opening the first form) creates a
global user object of the type referenced in your class module, and
populates it, perhaps by calling an Init method.
Then throughout your app you have access to that object through the
global variable. g_User.FirstNam e, etc.
-Tom.
Better yet is a public function that returns a reference to a private
User object. That way the object can be returned when it exists or
created and initialized if it doesn't. There's no need to create it at
startup. It's created the first time it is used.
On Wed, 05 Dec 2007 22:00:11 -0500, rkc <rk*@rkcny.yabb a.dabba.do.com>
wrote:
That's a good idea in some appliations, but the OP wrote:
"when user opens app, want to run some code that retrieves some
information specific to the user", so I fugured it would be
appropriate to initialize the object at startup time.
Do you have a code sample of the finer points of your implementation?
-Tom.
>Tom van Stiphout wrote:
>On Wed, 5 Dec 2007 17:26:14 -0800 (PST), mi************@ yahoo.com wrote:
YES! This is perfect for a class module. There is nothing wrong with declaring a more classic Type and having a global variable reference it, but an object representing the user is much more elegant and versatile.
Start your application with an AutoExec macro (rather than a startup form). It has just one command: RunCode, InitApplication () In a standard module write the public function InitApplication , which as part of its processing (before opening the first form) creates a global user object of the type referenced in your class module, and populates it, perhaps by calling an Init method. Then throughout your app you have access to that object through the global variable. g_User.FirstNam e, etc.
-Tom.
Better yet is a public function that returns a reference to a private User object. That way the object can be returned when it exists or created and initialized if it doesn't. There's no need to create it at startup. It's created the first time it is used.
On Wed, 5 Dec 2007 19:47:10 -0600, "Rick Brandt"
<ri*********@ho tmail.comwrote:
Agreed on the hidden form, but the class object is likely referenced
by a global variable, which would suffer from the same "unhandled
error" issue.
-Tom.
>mi************ @yahoo.com wrote:
>Assume the following: 1) multi-user environment 2) when user opens app, want to run some code that retrieves some information specific to the user...retrievi ng this information is somewhat i/o intensive, so would prefer to retrieve the info once at the beginning of the session, and have the data persist for the session 3) several forms in the app need to reference the information retrieved in #2 (the information specific to the user) 4) would prefer to have a solution where the information specific to the user (the info retrieved in #2) is NOT stored in a table...instead the information is stored in a VB data structure, and the VB code is organized such that: a) the data structure gets initialized when the user opens the app b) the information in the data structure persists while the user has the app open c ) the data structure is such that the code behind the forms that need the data have 'visibility' to the data in that data structure
So, my questions are: 1) Is there a 'best practices' way of setting up the VB data structure to handle the situation described above? If so, what would the outline of that be for this situation? 2) Is this, perhaps, a good candidate for the use of a class module?
Thank you.
Class module or just a hidden form with various controls to hold the values. You could use global variables but they can lose their values if an unhandled error occurs (MDB, not MDE). Class objects and hidden forms would not have this issue.
rkc <rk*@rkcny.yabb a.dabba.do.comw rote in
news:47******** **************@ roadrunner.com:
Better yet is a public function that returns a reference to a
private User object. That way the object can be returned when it
exists or created and initialized if it doesn't. There's no need
to create it at startup. It's created the first time it is used.
I'm not sure what you mean by a private "User object." You can write
functions that return values stored anywhere, and if they are data
that doesn't change during a user session, then you can use a STATIC
variable in the function and initialize it the first time the
function is called (though that doesn't work with Boolean
variables). I use this technique all the time so that things like
Windows logon and workstation name get looked up only once, the
first time the function is called.
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peter Foti |
last post by:
Simple question... which is better to use for defining font sizes and why?
px and em seem to be the leading candidates. I know what the general answer
is going to be, but I'm hoping to ultimately get some good real world
examples.
Fire away! :)
Regards,
Peter Foti
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their code
was littered with document.all and eval, for example, and I wanted to create
a practical list of best practices that they could easily put to use.
The above URL is version 1.0 (draft) that resulted. IMO, it is not a
replacement for the FAQ,...
|
by: Mark Anthony Spiteri |
last post by:
Hi,
I am designing an ASP.NET application in which particular pages require global variables that need to be persisted during postbacks. What is the best practice to do this?
Is it to use the viewstate object or is declaring the variables as static sufficient (I am currently using this method)?
Thank you,
|
by: Rod |
last post by:
I've written 2 ASP.NET applications (I've worked on one with a team and
another by myself). In my ASP.NET pages, when saving data to a backend
database I've done it by using the click event of a button and just using
the data during postback.
Now, however, I've got a WebForm that I'll be working on, and it is going to
collect more data than I have collected from the user in the past. I want to
be able to attempt to save each part and if...
|
by: Marc Gravell |
last post by:
Kind of an open question on best-practice for smart-client design. I'd
really appreciate anyones views (preferably with reasoning, but I'll take
what I get...). Or if anybody has any useful links on the subject? (and yes,
I have already googled it at length, but still no strong decision)
=============
After a long stint of pure-desktop / pure-server applications, I'm currently
working on a number of smart-client projects in C# using...
| |
by: Alan Silver |
last post by:
Hello,
MSDN (amongst other places) is full of helpful advice on ways to do data
access, but they all seem geared to wards enterprise applications. Maybe
I'm in a minority, but I don't have those sorts of clients. Mine are all
small businesses whose sites will never reach those sorts of scales. I
deal with businesses whose sites get maybe a few hundred visitors per
day (some not even that much) and get no more than ten orders per day....
|
by: Ned Balzer |
last post by:
Hi all,
I am pretty new to asp.net; I've done lots of classic asp, but am just
beginning to get my mind wrapped around .net.
What I'd like to do is include some code that tests if a user is logged
in, on each and every page, and redirects the user to a login page if
s/he's not logged in. The login page will also take care of some
standard setup, such as choosing/populating a user profile. I used to
use <!-- #include ... --for this,...
|
by: G |
last post by:
Hello,
Looking for opinions on a fairly simple task, new to ASP.net (C#) and want
to make sure I do this as efficiently as possible.
I have a web based form, and I need to run some SQL before submit, which
determines exactly where to send the form contents.
The table of "receipients" could contain in the region of 3,500 recipients
but is more likely to contain up to 1,000. Table structure:
|
by: Froefel |
last post by:
Hi group
I am creating a web application that uses a simple DAL as an
ObjectDataSource.
To retrieve data from the database, I use a DataReader object from
which I then assign the various fields to properties in an object,
like so:
in the DB, the fields are defined as follows:
ProjectID int NOT NULL
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |