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

Anyone interested in Access OOP sample code?

Status
Not open for further replies.

tcl

IS-IT--Management
Mar 5, 2001
15
US
I've been doing an Access project recently, but my previous gig was with Java and it prompted me to explore using OOP techniques with Access, so while I was waiting for my client to get rolling, I developed a non-trivial example of OOP with Access. The example creates a UI for an administrator to assign students to classes; a classic many-to-many relationship. I developed the UI 3 ways: using bound controls, using unbound controls, and using OOP. The bound version took about 2 pages of code. The unbound, about 2 1/2 to programmatically populate listboxes, and the OOP version about 10 pages. The OOP version is pretty sophisticated, though, it uses the Model-View-Controller model with a 3-tier architecture. After finishing, it's clear that the bound version was really quick to develop (an hour of work) at the cost of flexibility and control. The OOP version took nearly 2 days and is really flexible, but seems unjustifiable for a small project. Anybody interested in looking at the code and commenting? I'd be interested in other's opinions.

 
I'll take a peek. Do you have it on an ftp site or some-such? "The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!"
 
You can download the project from
It's a 700KB Access 2002 mdb. Check out the module named AboutThisProject for a description of which classes go with which sample. To run the bound, unbound, and OOP samples, just open the form, which is obviously named, i.e., frmAssignStudentsToClassesUnBound. To run the Person inheritance sample, run the TestImplementsStatement module. I'm pretty confident that if you browse the code and then maybe trace through it, you'll figure out how things are working pretty quickly. The class modules are pretty well commented. I'll be interested in any comments you have.
 
Ah, one thing I forgot to mention in the AboutThisProject module, the references. You'll need to have references to the following:
Microsoft DAO 3.6 Object Library
TypeLib Information (TLBINF32.dll)
Microsoft Scripting Runtime (scrrun.dll)

All should be in the System32 directory.
 
All my clients are with A97 and A2K, so I don't have 2002 installed. No promises, but I'll try get it installed on a test machine and take a peek.

I can open the mdb, but the code chokes on the .additem and .removeitem methods which aren't available in A2K. "The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!"
 
I just finished porting the project to VB6. The code ported fine except for the "Option Compare Database" statements and the Access Listbox controls. I had to replace the Listbox controls with the ListView Common Control to provide similar functionality. VB's native listboxes don't support multiple columns. One mistake is that I shouldn't have assigned the form controls to the controller classes member variables directly; instead, I should have built wrappers for the textbox and listbox controls so that I could swap the control types without touching the controller code.
 
I mispoke before, the mdb is in the Access 2k format, not 2k2.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top