John W. Colby
jcolby at colbyconsulting.com
Wed Feb 12 16:27:00 CST 2003
LOL. It definitely isn't "my book". I was hired to help update the book to the next rev of Access (XP). However I am now working on the NEXT rev (for the office version in Beta) and that is going to be a complete rewrite. Myself, one of the original authors, and one of the other 5 guys working on the last book. IOW three of us, rewriting it pretty much from scratch. Moving to ADO etc. So that will be "my book" (kinda). And BTW, Martin is a tech editor on this new one. Anyway, no, all of my class experience is NOT in (or related to) the book, nor will it be in the next one. The title kinda locks us in to what we can put in it... BEGINNING Access XXX VBA. But I also wrote a series of articles on classes, discussing a lot of what we are talking about here. Those are on our web site. I started using classes hmmm... about 3 or 4 years ago now. I started seeing the occasional cryptic message about WithEvents from this Russian Guy (Shamil) which caught my attention. I went to his site and downloaded all of his demos, but had a bit of a rough time understanding the concept. Looking back, I don't really understand why. It's really easy stuff but I did. Tried it, went away, tried it, went away. Finally one time it just clicked. It clicked so well that I decided to completely rewrite my framework to be class / withevents driven. Which I did. Now I use classes and withevents everywhere. But to get here I have written an entire framework with probably 39 classes, of which 19 are WithEvents based. My framework is now a really cool thing (in my eyes anyway) that can be initialized by initializing a class. It reads parameters out of a table in the framework MDA to set up it's operation, reads parameters out of an additional SysVar table in the FE to set up the framework for this specific front end, and finally reads SysVars out of a table to set up the application itself. I have classes for zipping and unzipping files (uses Raisevents even!), classes for encrypting and decrypting stuff (from a thread awhile back), classes to upload and download files from the web, etc. Once you get a framework like this set up, it can dramatically lower your development costs for front ends. Anyway, enough on that. Classes and Withevents, great stuff. John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-admin at databaseadvisors.com [mailto:accessd-admin at databaseadvisors.com]On Behalf Of John Bartow Sent: Wednesday, February 12, 2003 4:17 PM To: accessd at databaseadvisors.com Subject: RE: [AccessD] Just curious John, Is all of your class experience related in your book? Your's and whoever those other guys are I mean. ;o) I'm just kidding Martin! -----Original Message----- From: accessd-admin at databaseadvisors.com [mailto:accessd-admin at databaseadvisors.com]On Behalf Of John W. Colby Sent: Wednesday, February 12, 2003 2:33 PM To: accessd at databaseadvisors.com Subject: RE: [AccessD] Just curious John, This is where a class comes in handy. The class is passed in a pointer to a specific control (text box in your example). The class sinks the events for whatever control is passed in using Withevents. So the class can perform whatever action you find useful. Now the trick is to build a scanner that looks through all of the form's controls collection - me.controls(), looking for all controls of that control type. Load an instance of the class every time a text box is found. Save a pointer to the class in a collection so that they don't immediately unload again. Unload the class collection when the form closes. Voila, all your text boxes do something. It's the details of the voila that are the problem. Once you understand classes and Withevents, it is trivial to do this. I can at this point write a class to do this and a scanner to find and instantiate an instance of the class for every text box.. in about an hour. In fact my framework does exactly this. I have a form class that is loaded in the form's OnOpen. The form class has a control scanner that finds every control. I have a class for all of the data aware controls. So the scanner in the control class loads an instance of the combo class for every combo, an instance of the text box class for every text box, checkbox class for every checkbox etc. And in fact my text box control class has the very behavior you are discussing (turn the background a different color) so that I can turn on this behavior with a simple switch. My combo box class understands what to do with the combo box NotInList and dblClick. Etc. Etc. Classes and Withevents. POWERFUL stuff! John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-admin at databaseadvisors.com [mailto:accessd-admin at databaseadvisors.com]On Behalf Of John Clark Sent: Wednesday, February 12, 2003 3:10 PM To: accessd at databaseadvisors.com Subject: [AccessD] Just curious I have a question that really does not pertain to anything that I am currently doing...other than it may open up some ideas for me...but I have been curious about it. If you want to do something to all controls, or all text boxes, on a form, how would you do this, without placing code behind each and every control. As I am writing this, it is occurring to me that something like this may have been posted in the past...don't remember exacts. Examples of what I would like to do are: 1) I would like to set fields so that when you click on them, with the mouse, you are taken to the beginning of the field, and maybe the end, if there were already data existing. I have done this for individual fields, and the users like it, but I was just to dang lazy to do them all. 2) There was a program in the past, where for a reason that I no longer remember, I had programmed each field to become "pale yellow," when it gained focus, and return to white, when it lost focus. I did this for each and every field, and it was a pain in the backside. Again, I am really just curious at this point, but I can think of several standards that I might input into my programs, once I figure this out. Take care! John W Clark _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com