Solved

Data tree structure

Posted on 1997-07-22
5
248 Views
Last Modified: 2006-11-17
I found it is difficult to remember the names of iterms in database. Can you list the full tree structure here something like:

Data1.Recordset.Fields(i).Name
-------------------------.Type
---------------.Fields.Count
-----.Database.Tabledefs(i).Name
--------------.Tabledefs.Count
0
Comment
Question by:victorlong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Expert Comment

by:ESI
ID: 1428637
You'll find an example doing exactly what u need in the DAO Reference, either under Fields or Tabledefs,....
0
 
LVL 9

Expert Comment

by:cymbolic
ID: 1428638
ESI is "Write" on.  VB contains an example in the help system showing you how to iterate through the tables and pull up all column properties.  If you give me an email address, I'll ship you some code that:

1) shows three linked listboxes, #1 all tables, # 2 columns and properties for  selected table, and #3, sample data for selected record.  All using DAO.  It calculates all space useage and average space per column for database as well as total columns in db.  I wrote it as a handy little tool, because you don't need an MSAccess sledge hammer to do a tack hammer's job!
0
 
LVL 3

Accepted Solution

by:
ChrisLewis earned 50 total points
ID: 1428639
Since no one gave you any code, try this.  Make sure you reference DAO 3.0 or 3.5

Private Sub Dir1_Change()
  File1.Path = Dir1.Path
End Sub

Private Sub Form_Load()
  Dir1.Path = "C:\My Documents"
End Sub

Sub command1_click()
  Dim dbDatabase As Database
  Dim tdefTable As TableDefs
  Dim iCount As Integer
  Dim iCount2 As Integer
 
  'Set dbDatabase = OpenDatabase(File1.Path & "\" & File1.filename, False, True, ";pwd=test")
  Set dbDatabase = OpenDatabase(File1.Path & "\" & File1.filename, False, True)
  MsgBox dbDatabase.Version
  Set tdefTable = dbDatabase.TableDefs
  Text1.Text = ""
  For iCount = 0 To tdefTable.Count - 1
    'Text1.Text = Text1.Text & tdefTable(iCount).Name & vbCrLf
    If tdefTable(iCount).Attributes <> dbSystemObject And tdefTable(iCount).Attributes <> dbHiddenObject Then
      Text1.Text = Text1.Text & tdefTable(iCount).Name & vbTab & tdefTable(iCount).Connect & vbCrLf
      For iCount2 = 0 To tdefTable(iCount).Fields.Count - 1
        Text1.Text = Text1.Text & vbTab & tdefTable(iCount).Fields(iCount2).Name
        Select Case tdefTable(iCount).Fields(iCount2).Type
        Case dbBigInt
          Text1.Text = Text1.Text & vbTab & "Big Integer"
        Case dbBinary
          Text1.Text = Text1.Text & vbTab & "Binary"
        Case dbBoolean
          Text1.Text = Text1.Text & vbTab & "Boolean"
        Case dbByte
          Text1.Text = Text1.Text & vbTab & "Byte"
        Case dbChar
          Text1.Text = Text1.Text & vbTab & "Char"
        Case dbCurrency
          Text1.Text = Text1.Text & vbTab & "Currency"
        Case dbDate
          Text1.Text = Text1.Text & vbTab & "Date / Time"
        Case dbDecimal
          Text1.Text = Text1.Text & vbTab & "Decimal"
        Case dbDouble
          Text1.Text = Text1.Text & vbTab & "Double"
        Case dbFloat
          Text1.Text = Text1.Text & vbTab & "Float"
        Case dbGUID
          Text1.Text = Text1.Text & vbTab & "Guid"
        Case dbInteger
          Text1.Text = Text1.Text & vbTab & "Integer"
        Case dbLong
          Text1.Text = Text1.Text & vbTab & "Long"
        Case dbLongBinary
          Text1.Text = Text1.Text & vbTab & "Long Binary (OLE Object)"
        Case dbMemo
          Text1.Text = Text1.Text & vbTab & "Memo"
        Case dbNumeric
          Text1.Text = Text1.Text & vbTab & "Numeric"
        Case dbSingle
          Text1.Text = Text1.Text & vbTab & "Single"
        Case dbText
          Text1.Text = Text1.Text & vbTab & "Text"
        Case dbTime
          Text1.Text = Text1.Text & vbTab & "Time"
        Case dbTimeStamp
          Text1.Text = Text1.Text & vbTab & "Time Stamp"
        Case dbVarBinary
          Text1.Text = Text1.Text & vbTab & "VarBinary"
      End Select
      Text1.Text = Text1.Text & vbTab & tdefTable(iCount).Fields(iCount2).Size & vbTab & tdefTable(iCount).Fields(iCount2).Attributes & vbCrLf
      Next
    End If
  Next iCount
 
  Set tdefTable = Nothing
  Set dbDatabase = Nothing
End Sub

There is a ton of information you can get from DAO.  Just play a round with it.

Hope this helps.

chris
0
 

Author Comment

by:victorlong
ID: 1428640
Hi ChrisLewis...,

I am confused...what is your code for? Does that print out what I heed?

I want a list / tree to show
WHAT MAY BE ADDED AFTER DATA1 AND THE DOT something like

Data1.Recordset.Fields(i).Name
Data1.Recordset.Fields(i).Type
Data1.Recordset.Fields.Count
Data1.Database.Tabledefs(i).Name
             
and whatever I don't know.

Regards.

Victor
0
 
LVL 3

Expert Comment

by:ChrisLewis
ID: 1428641
I see.  Look in the VB help file for properties of a Database Object and a TableDef object.

From the Help File:
---------------------------
Database Object
---------------------------
A Database object contains these collections, methods, and properties.

Collections
---------------------------
Containers
Properties
QueryDefs
Recordsets (Default for )
Relations
TableDefs (Default for )

Methods
---------------------------
Close
CreateProperty
CreateQueryDef
CreateRelation
CreateTableDef
Execute
MakeReplica
NewPassword
OpenRecordset
PopulatePartialSynchronize

Properties
---------------------------
CollatingOrder
Connect
Connection
DesignMasterID
Name
QueryTimeout
RecordsAffected
Replicable (user-defined)
ReplicaID
Updatable
V1xNullBehavior
Version
---------------------------
---------------------------

---------------------------
TableDef Object
---------------------------
A TableDef object contains these collections, methods, and properties.

Collections
---------------------------
Fields (Default)
Indexes
Properties
Methods
CreateField
CreateIndex
CreateProperty
OpenRecordset
RefreshLink

Properties
---------------------------
Attributes
ConflictTable
Connect
DateCreated
KeepLocal (user-defined)
LastUpdated
Name
RecordCount
Replicable (user-defined)
ReplicaFilter
SourceTableName
Updatable
ValidationRule
ValidationText
---------------------------
---------------------------

For the fields object, look at the help file.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question