Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Data tree structure

Posted on 1997-07-22
5
Medium Priority
?
251 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 200 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] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

715 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