[AccessD] Using Multidimensional Arrays

John Colby jwcolby at ColbyConsulting.com
Tue Mar 7 07:55:40 CST 2006


I agree with Jim.

One of the programming structures available for us to use in Access is
called a class.  A class is a place to store information, along with the
code required to manipulate that information.

So for example, you could create an email info class that holds all of the
information about one "record" - First name, Last name, Email Address.  

1) You then instantiate the email info class and load one person's info in
it.  
2) You save the pointer to the email info class in a collection.  The nice
thing about collections is that you can "key" them if you want to.  So you
might save it keyed on the email address, or the first name and last name
concatenated - assuming you need this.
3) You then build a second class - what I call a controller or supervisor
class - that reads the data and instantiates all of these records and saves
them in a collection in the controller class.  The controller then has all
of the code that you will use to do the checking.  It can iterate through
the collection of email classes performing the checks that you mention.  

Place code close to the data used.  For example, if you are going to
concatenate the name fields, place the code to do that in the email info
class, just build a method called WholeName which concatenates the two name
variables and returns the result.  Doing this makes the concatenation
identical everywhere that you need the data concatenated and it is a
function of the email info class to return the data formatted as it is
needed.

The code to do the Outlook lookup and manipulation may be in the controller
class, or you might have a dedicated Outlook class that "knows about" the
Email Info Controller class and asks it for data.

Classes are very powerful and used with collections to store the class
instances, makes the "array" thing obsolete.  Classes and collections will
not be as fast as direct array manipulation, but it will be fast and it will
allow much better documentation and so forth as you break the task down into
logical pieces.

BTW, one thing that people often get confused about is how much overhead is
created by having the code in classes.  Is the code reloaded for each
instance of the class?  The answer is that the code is loaded once when the
first class instance is loaded.  The DATA storage in memory is created for
each class instance as it is loaded.  So the code is literally shared,
whereas the data (variables) is only created as it is needed - as an
instance is loaded.  There is no "additional overhead" for loading the code
over and over again.

John W. Colby
www.ColbyConsulting.com 


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jim DeMarco
Sent: Tuesday, March 07, 2006 7:58 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Using Multidimensional Arrays

Here's a case where I'd use a custom collection class rather than an array.
You can refer to my article in the March O5 list newsletter for details but
I think you'll find it easier to navigate than an array.

As I see it you'll create a cMailInfo class containing Name (do your
concatenation on the way in if possible otherwise add FName, LName
properties instead) and EmailAddress properties, then a custom collection
class, cMailInfoColl, to hold cMailInfo items.  You can grab the cContacts
collection class from the article and make a few simple mods to accommodate
this scenario.

Glad to answer any questions on it.

HTH

Jim DeMarco

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Penn White
Sent: Tuesday, March 07, 2006 5:29 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Using Multidimensional Arrays

ACC03 - I'm sending out emails from Access to a list of recipients selected
from a listbox.  Since I don't have Exchange Server, I can't be sure that
the entries in the 'workstations' Outlook Contact list is up-to-date. 
Consequently, I have to verity first that the Contact is in that
workstation's Outlook Contact list and second that the email address hasn't
changed.  It's a bit messy and may be time consuming since every single
email will have to check all the recipients before being sent but there
would rarely be more than 10 recipients for an email and more usually only
2-3 and I can't think of any other way to do it.

I was thinking of creating a multi-dimensional array to hold the FirstName,
LastName and Email address for each selected recipient but I can't figure
out how to do it.  The number of entries in the array will vary depending on
how many recipients are selected.  There may not necessarily be a first name
and the 'last name' may actually be a string of several words, like "Belton
Manufacturing" for example.

Once the array is created, I'll need to concatenate the first and last names
and check them against the existing entries in Outlook Contacts, updating or
adding as necessary.  If I can get the entries out of the array, that won't
be hard, I've already done if before and have developed functions for the
various pieces.

I've also seen some comparisons between using structures and arrays and
maybe I should be using a structure here.

I'm a bit befuddled.

Penn 

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


****************************************************************************
*******
"This electronic message is intended to be for the use only of the named
recipient, and may contain information from Hudson Health Plan (HHP) that is
confidential or privileged.  If you are not the intended recipient, you are
hereby notified that any disclosure, copying, distribution or use of the
contents of this message is strictly prohibited.  If you have received this
message in error or are not the named recipient, please notify us
immediately, either by contacting the sender at the electronic mail address
noted above or calling HHP at (914) 631-1611. If you are not the intended
recipient, please do not forward this email to anyone, and delete and
destroy all copies of this message.  Thank You".
****************************************************************************
*******

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list