Connecting Tech Pros Worldwide Forums | Help | Site Map

How to disclose attributes of an entity

Newbie
 
Join Date: Mar 2008
Posts: 18
#1: Mar 23 '08
Ok, this is little tough atleast for me. I want to design a form that has all of my seven entities and I want a check box next to each of those seven entities. Now, when I click any one of these check box, I should be able to get its attributes with a check box next to it. That means initially its attributes are hidden and they pop up as soon as I select the check box of the main entity. After I am done selecting the attributes that I want, I want them to show up in a report. I know this might be a lot of work but I will appreciate with any kind of help.

Thanks for your time guys.

Hulas

mshmyob's Avatar
Expert
 
Join Date: Jan 2008
Location: witness protection
Posts: 618
#2: Mar 23 '08

re: How to disclose attributes of an entity


If by entities you mean tables then the 'talented' Allen Browne has already done this for you. Just cut and paste this code and make the changes to meet your requirements.

Expand|Select|Wrap|Line Numbers
  1. Function TableInfo(strTableName As String)
  2. On Error GoTo TableInfoErr
  3.    ' Purpose:   Display the field names, types, sizes and descriptions for a table.
  4.    ' Argument:  Name of a table in the current database.
  5.    Dim db As DAO.Database
  6.    Dim tdf As DAO.TableDef
  7.    Dim fld As DAO.Field
  8.  
  9.    Set db = CurrentDb()
  10.    Set tdf = db.TableDefs(strTableName)
  11.    Debug.Print "FIELD NAME", "FIELD TYPE", "SIZE", "DESCRIPTION"
  12.    Debug.Print "==========", "==========", "====", "==========="
  13.  
  14.    For Each fld In tdf.Fields
  15.       Debug.Print fld.Name,
  16.       Debug.Print FieldTypeName(fld),
  17.       Debug.Print fld.Size,
  18.       Debug.Print GetDescrip(fld)
  19.    Next
  20.    Debug.Print "==========", "==========", "====", "==========="
  21.  
  22. TableInfoExit:
  23.    Set db = Nothing
  24.    Exit Function
  25.  
  26. TableInfoErr:
  27.    Select Case Err
  28.    Case 3265&  'Table name invalid
  29.       MsgBox strTableName & " table doesn't exist"
  30.    Case Else
  31.       Debug.Print "TableInfo() Error " & Err & ": " & Error
  32.    End Select
  33.    Resume TableInfoExit
  34. End Function
  35.  
  36.  
  37. Function GetDescrip(obj As Object) As String
  38.     On Error Resume Next
  39.     GetDescrip = obj.Properties("Description")
  40. End Function
  41.  
  42.  
  43. Function FieldTypeName(fld As DAO.Field) As String
  44.     'Purpose: Converts the numeric results of DAO Field.Type to text.
  45.     Dim strReturn As String    'Name to return
  46.  
  47.     Select Case CLng(fld.Type) 'fld.Type is Integer, but constants are Long.
  48.         Case dbBoolean: strReturn = "Yes/No"            ' 1
  49.         Case dbByte: strReturn = "Byte"                 ' 2
  50.         Case dbInteger: strReturn = "Integer"           ' 3
  51.         Case dbLong                                     ' 4
  52.             If (fld.Attributes And dbAutoIncrField) = 0& Then
  53.                 strReturn = "Long Integer"
  54.             Else
  55.                 strReturn = "AutoNumber"
  56.             End If
  57.         Case dbCurrency: strReturn = "Currency"         ' 5
  58.         Case dbSingle: strReturn = "Single"             ' 6
  59.         Case dbDouble: strReturn = "Double"             ' 7
  60.         Case dbDate: strReturn = "Date/Time"            ' 8
  61.         Case dbBinary: strReturn = "Binary"             ' 9 (no interface)
  62.         Case dbText                                     '10
  63.             If (fld.Attributes And dbFixedField) = 0& Then
  64.                 strReturn = "Text"
  65.             Else
  66.                 strReturn = "Text (fixed width)"        '(no interface)
  67.             End If
  68.         Case dbLongBinary: strReturn = "OLE Object"     '11
  69.         Case dbMemo                                     '12
  70.             If (fld.Attributes And dbHyperlinkField) = 0& Then
  71.                 strReturn = "Memo"
  72.             Else
  73.                 strReturn = "Hyperlink"
  74.             End If
  75.         Case dbGUID: strReturn = "GUID"                 '15
  76.  
  77.         'Attached tables only: cannot create these in JET.
  78.         Case dbBigInt: strReturn = "Big Integer"        '16
  79.         Case dbVarBinary: strReturn = "VarBinary"       '17
  80.         Case dbChar: strReturn = "Char"                 '18
  81.         Case dbNumeric: strReturn = "Numeric"           '19
  82.         Case dbDecimal: strReturn = "Decimal"           '20
  83.         Case dbFloat: strReturn = "Float"               '21
  84.         Case dbTime: strReturn = "Time"                 '22
  85.         Case dbTimeStamp: strReturn = "Time Stamp"      '23
  86.  
  87.         'Constants for complex types don't work prior to Access 2007.
  88.         Case 101&: strReturn = "Attachment"         'dbAttachment
  89.         Case 102&: strReturn = "Complex Byte"       'dbComplexByte
  90.         Case 103&: strReturn = "Complex Integer"    'dbComplexInteger
  91.         Case 104&: strReturn = "Complex Long"       'dbComplexLong
  92.         Case 105&: strReturn = "Complex Single"     'dbComplexSingle
  93.         Case 106&: strReturn = "Complex Double"     'dbComplexDouble
  94.         Case 107&: strReturn = "Complex GUID"       'dbComplexGUID
  95.         Case 108&: strReturn = "Complex Decimal"    'dbComplexDecimal
  96.         Case 109&: strReturn = "Complex Text"       'dbComplexText
  97.         Case Else: strReturn = "Field type " & fld.Type & " unknown"
  98.     End Select
  99.  
  100.     FieldTypeName = strReturn
  101. End Function
  102.  
cheers,

Quote:

Originally Posted by Hulas

Ok, this is little tough atleast for me. I want to design a form that has all of my seven entities and I want a check box next to each of those seven entities. Now, when I click any one of these check box, I should be able to get its attributes with a check box next to it. That means initially its attributes are hidden and they pop up as soon as I select the check box of the main entity. After I am done selecting the attributes that I want, I want them to show up in a report. I know this might be a lot of work but I will appreciate with any kind of help.

Thanks for your time guys.

Hulas

Reply