[AccessD] Class module builder

Gustav Brock Gustav at cactus.dk
Tue Apr 12 13:01:17 CDT 2005


Hi Jim

Could it be Larry Diener?

Date: 19-07-1999 15:34:58
Subject: 	RE: [accessd] Tool for creating class modules from
tables or queries

I have sent copies of the ClassBuilder form to all who have requested
it
so far.  If you asked me for it and have not received it please ask
again.  There was a minor code modification which I sent directly to
those who needed it.  It corrected a problem where the first field of
the record was not accounted for in the GetData and SaveData methods.
If you received the code modification, please do not distribute the
utility without replacing existing code with the code I sent.  If you
don't feel comfortable doing this let me know and I'll send you a new
copy of the form. 

Mark Breen asked two questions which I thought those interested in the
utility might benefit from the responses.

1) I presume you are using this in conjunction with SQL Server?
Any comments to make ?  Does it work well ?

I am using the utility for Access and SQL tables and queries.  I have
also tested it on attached CSV files.  Essentially anything that
Access
allows you to link to should work.  The only limitations are that if
the
utility cannot detect a primary key (named 'PrimaryKey') then the
where
clause can not be automatically determined.  One could modify the
routine to enumerate the existing indexes on a table ant then pick one
for use.  I'll leave this as an exercise for the reader.   Also, field
types are determined if possible.  If a field type cannot be
determined
or is not in a predefined list the field and its working variables are
typed as variants in the class.  Some would say that this is an
advantage since variants handle nulls and explicitly typed variables
do
not.  One could easily modify the select case statement in the
CreateTableClass() function for more resolution. 

It works well for my purposes.  Other Property builders I've seen
build
one variable at a time and I've almost always needed to create a
record
class for all the fields in a table.  Personally, I'm thrilled with
it.
It has worked for me in every instance that I have used it and it has
saved a great deal of typing time.  

2) BTW, when you create an Access FE, do you still create linked
tables
an use these as record sources for the forms ?  

I typically use an Access FE and a SQL backend.  I still link all my
SQL
tables to the database then I create classes to handle specific cases
or
complex situations where I need to control several records from
different tables as a unit.  In one specific case where I recently
normalized a complex table based on standard hospital bill forms
(UB-92)
into three separate tables, I built several classes to accommodate the
data in each table and then built relationships between the classes
using collection classes.  To make a long story short, the
statisticians
are very happy because the tables are normalized and the changes were
transparent to the user because the form is the same.  Underneath it
all
though is a faster and more controlled record creation and retrieval
'engine' handled by the classes. It is faster because the class only
handles a single record, or a limited group of records in the case of
a
collection, and the data are stored in memory (somewhat like an array)
while being used. 

Like arrays, classes can't be used directly as recordsources (AFAIK)
so
at least three other functions are required to make practical use of
them on forms.  First you need a 'scatter' function which initializes
the class, calls the getdata method and then distributes the data to
the
unbound controls on your form.  I usually call this function in the
onload event of the form. Second, you need a 'gather' function which
collects the data from the form and writes it back to the underlying
data source. Third Unbound forms don't have a dirty property so you
need
to simulate the dirty property by comparing the data in the unbound
controls to the data in the underlying record being viewed.  

I'll stop there and suggest a few references for our review.  

Chapter 3 in the ADH discussed class based forms.
MS KB articles:  Q177972, Q160007 , Q159827, Q160012   

I don't consider my self an expert on classes (or much else for that
matter :-)) but I'd be happy to continue this discussion if there is
additional interest.  I can also provide you with a simple example of
a
form using the scatter and gather functions as well as the
IsRecordDirty
function if you'd like.

Regards,

Larry           
-- 


>>> Jdemarco at hudsonhealthplan.org 04/12 7:48 pm >>>
I think I got one from Arthur Fuller but I think it was on my last PC
(that crashed).

Is Arthur lurking about?

Jim DeMarco

-----Original Message-----
From: accessd-bounces at databaseadvisors.com 
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Neal Kling
Sent: Tuesday, April 12, 2005 1:11 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Class module builder


It was either for 97 or 2K. It's been a couple/few of years since I've
used it and I don't recall.

Neal

-----Original Message-----
From: accessd-bounces at databaseadvisors.com 
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Charlotte
Foust
Sent: Tuesday, April 12, 2005 1:02 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Class module builder


The one Dev and Terry built is the only one I ever worked with.  What
version of Access was it for?

Charlotte Foust


-----Original Message-----
From: Neal Kling [mailto:nkling at co.montgomery.ny.us] 
Sent: Tuesday, April 12, 2005 9:41 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Class module builder


I used to have a utility that would build a class module. I don't
remember whether it was implimented as a module or a form or what, but
basically I'd pass it the name of a table and it would build a class
module, complete with get/let statements that would let me work with
the
records. I've lost it and I'm looking for it.

I found Dev Ashish and Terry Kreft's Class Builder Wizard, but that's
not it.

Any help?

Thanks,
Neal




More information about the AccessD mailing list