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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class modules: what's the point of all the steps? 1

Status
Not open for further replies.

sub5

Programmer
Oct 12, 2005
104
I am learning Class Modules in access. I am looking at the "Cats" example in Access 97 Developer's Handbook
by Litwin, Getz, and Gilbert.

Basically when a user wants to change details of a cat, they open a form using unbound controls and they select a cat id. The programing then goes through multiple procedures in the forms class module and the cats class module to pull the data. The user changes something, then again multiple procedures and variables are used from the to modules to put the revised data back into the cats table.

Why go through all that programming when you could just have a bound form to the cats table? (data validation can be in the form and table)

(I know it's good to use a simple example to illustrate a complex principle, but I struggle to see the reason for the class module for something like this.)

I am sure I am missing some key benefit.

Anyone know any other class module examples out there?
 
when you use the same code over and over and over again and need to make a simple change over and over and over again you will begin the path towards enlightenment ...

when you make the same simple change in all but one or two locations that need to be changed you will be farther along the path of elightenment ...



 
I agree with bdbBear but,
is your point highlighted in sub5's example?

I'm not familiar with the example or context he gave but, offhand, it does seem a bit overkill.

But, I could speculate and say, it preserves users from
messing with "finished" data.
But then again, what's wrong with DataMode...

...djoo go' me meng!
 
I think learning OOP and custom classes, custom collections, and custom events is not the easiest in Access in order to see the applicability. However once you learn OOP you will never code the same way again.
Here are a couple examples. Someone on this site had 4000 lines of code for a form because they had hundred of controls that they were trapping events. I built a custom class module that passed in each control with a loop. Then I could trap with a single event. Got the code down to about 50 lines.
I also have my own custom classes for Image controls and treeview controls. In order to build a treeview from a query or table, I pass in the treeview control, the table name, and a couple of fields and set a few properties of my custom class. Thats it, the form loads and populates a treeview with drag and drop cababilities. This would take a very long time to code for individual forms. Basically I have a treeview class that functions like an Access control.
That example in 97 Desktop may not be so good, I have 2002 Developers handbook and the examples are pretty good. Trust me if you want to bring your coding up to the next level spend some time learning this.
 
Thanks MajP, I'll try and get hold of a 2002 h/book and look at the egs. Do you have any other recommendations for sources to learn OOP?
 
I learned to code in JAVA so I had a strong OOP background before learning VB so I do not have any recommendations for good books. However, I would look for a generic books in OOP for VB. I would learn the concepts there first and then try to apply them to Access programming. Database concepts lend well to OOP, but may not be the best teaching tools.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top