DWUTKA at marlow.com
DWUTKA at marlow.com
Tue Nov 15 17:24:44 CST 2005
Not really, you can get the data type of the field, the field name, and even the description of the field. It would be a simple select case to build a property Let and Get statement for each field. To go a bit further, you should also be able to determine if a field is an ID field, or get the indexes of the field to build an ID. I would make it straightforward, that if there is an autonumber field, you include a 'get and write' capability. Normally, when I build this type of class structure, I include a StorageOnly boolean value, that sets to false when the class loads. Then, when you set the value of the ID field, if StorageOnly is True, it does nothing but stores the value, if it's false, then it goes and 'fills itself' with that particular record. Then add a 'Save' Function. When the class initializes, you set an internal value that states the record is 'new'. When you set the ID field, it also sets that value to 'old'. When you run the save function, it either creates a new record with said values or updates the existing records of that table. That way, the second 'collection' class can set the StorageOnly property to true, to pull all of the records up at once, or you can create a single instance of your 'record' class and by setting it's ID property, it automatically retrieves it's data for you. An Add-in could use the properties of the field to create the property names within the class, along with comments, etc. I could build one for you, but I would do it in VBA, so it would be a VB6 add-in. I think you use .Net, which uses slightly different code for properties (if I remember right, you go Property Something() then have a Get and Let statement within the property....only played around with .Net a little bit). You could even have the Let() statements set a 'dirty' property, and have a 'reset' function to restore the original values and clear the dirty property. Let me know if you want me to build something like this in VB6, I could send you the VB6 Add-in code then...shouldn't require too much change to work in .Net. Drew -----Original Message----- From: John Colby [SMTP:jwcolby at colbyconsulting.com] Sent: Tuesday, November 15, 2005 1:05 PM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Building classes for tables Sure, of course except that the "information of the record" is pretty structured and a PITA to have to do every time. The "records in the table" is more specific to the application, and so less can be done with a wizard. John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of DWUTKA at marlow.com Sent: Tuesday, November 15, 2005 1:57 PM To: accessd at databaseadvisors.com Subject: Re: [AccessD] Building classes for tables Ya, I meant field, not table. Shouldn't be too hard, but I think you would want it to make 2 classes. One class to hold the information of the record, and one class to hold the 'records' in a collection. Drew -----Original Message----- From: John Colby [SMTP:jwcolby at colbyconsulting.com] Sent: Monday, November 14, 2005 8:34 PM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Building classes for tables I am discussing building a CLASS, inserted into the modules collection in Access, where a table is specified. Once the table is specified, a PRIVATE variable for is created each field in the table in the header of the class, and a property get/let is created for each private variable. In other words, specify the table name and press the button. Look in the modules tab and find a new class with private variables and public property get/let methods for each field in the table. A Class builder. I can then take that class "template" and start adding init code, and custom methods etc. This is doable, but it is a long time since I tried mucking with the VBA editor object. John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of DWUTKA at marlow.com Sent: Monday, November 14, 2005 5:15 PM To: accessd at databaseadvisors.com Subject: Re: [AccessD] Building classes for tables I had built a 'Properties' property. It was an Add-in to VB. Though I don't think building one to create a property for each table would be too difficult. Drew -----Original Message----- From: John Colby [mailto:jwcolby at colbyconsulting.com] Sent: Monday, November 14, 2005 2:39 PM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Building classes for tables 8-( I could swear that someone a long time ago mentioned building an automatic class builder. Oh well. Perhaps I should build one. ;-) John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust Sent: Monday, November 14, 2005 3:29 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Building classes for tables Sounds like a dot net Typed Dataset to me, John. Charlotte Foust -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John Colby Sent: Monday, November 14, 2005 11:33 AM To: 'Access Developers discussion and problem solving' Subject: [AccessD] Building classes for tables I seem to remember someone saying that they had designed a tool to build a class for a given table, i.e. variables to hold the data in the fields, and property get/let statements for each variable. Has someone done this? Is it available? John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -- 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 -- 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 -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com