artful at rogers.com
artful at rogers.com
Sun Feb 11 10:21:46 CST 2007
Thanks, Shamil. I will play with this. The point behind all this is a situation in which the customer can define N product attributes. So we have two tables: Products (which defines the basic attributes that all client products have in common, and the user-defined product attributes, which are actually recorded as rows but then assimilated into columns on a single row, from which is generated said AutoForm). Assuming that the UDAs (user-defined attributes) are defined completely (i.e. this column needs phone-formatting, that column needs short-date formatting, etc.), then I'm imagining a form with a pair of tabs, the first of which displays the columns that all products share, while the second displays the columns the user has defined. Thus the need for an AutoForm. Client A has defined 10 attributes, Client B has defined 15. I don't want to rewrite the UI for each new client. I want to generate the UDA form and plonk it on the Tab2 automagically. Arthur Fuller Technical Writer, Data Modeler, SQL Sensei Artful Databases Organization www.artfulsoftware.com ----- Original Message ---- From: Shamil Salakhetdinov <shamil at users.mns.ru> To: Access Developers discussion and problem solving <accessd at databaseadvisors.com> Sent: Sunday, February 11, 2007 9:06:49 AM Subject: Re: [AccessD] Abstract question Hello Arthur, The task of "realizing that certain fields of any arbitrary recordset ought to be checkboxes, others formatted short-date, etc." can be solved by using recordset field's DisplayControl property, which defines what is a preferable way to display field's value: DisplayControl = 109 - textbox DisplayControl = 106 - checkbox DisplayControl = 110 - listbox DisplayControl = 111 - combobox Format property defines output format etc. You can find other useful properties to generate autoform - the following code can be used for that if you uncomment two code lines in Case Else code block: Public Sub TestDebugPrint(ByVal vstrRstName As String) Dim dbs As DAO.Database Dim rst As DAO.Recordset Dim fld As DAO.Field Dim fld1 As DAO.Field Dim prp As DAO.Property Set dbs = CurrentDb Set rst = dbs.OpenRecordset(vstrRstName) For Each fld In rst.Fields With fld Debug.Print .Name For Each prp In fld.Properties With prp Select Case .Name Case "DisplayControl", "Format": Debug.Print vbTab & prp.Name & " = " & _ propertyValue(prp) Case Else 'Debug.Print vbTab & prp.Name & " = " & _ ' propertyValue(prp) End Select End With Next prp End With Next fld End Sub Private Function propertyValue(ByRef rprp As DAO.Property) As Variant On Error GoTo HandleErr propertyValue = rprp.Value Exit Function HandleErr: propertyValue = "(N/A)" End Function -- Shamil -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of artful at rogers.com Sent: Sunday, February 11, 2007 3:31 PM To: AccessD at databaseadvisors. com Subject: [AccessD] Abstract question Does anyone have an idea how to generate an autoForm from any arbitrary recordset? Ideally, such a class would have the smarts to realize that certain fields ought to be checkboxes, others formatted short-date, etc. Arthur -- 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