Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Data tree structure

Posted on 1997-07-22
5
Medium Priority
?
255 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
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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library 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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

578 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