Solved

Data tree structure

Posted on 1997-07-22
5
249 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

728 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