home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / ch_code / ch11 / dbstruct / dbstruct.frm (.txt) next >
Encoding:
Visual Basic Form  |  1997-02-20  |  7.7 KB  |  247 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
  3. Begin VB.Form Form1 
  4.    Caption         =   "Database Structure"
  5.    ClientHeight    =   6285
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   7605
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   6285
  11.    ScaleWidth      =   7605
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.TextBox txtSQL 
  14.       BeginProperty Font 
  15.          Name            =   "MS Sans Serif"
  16.          Size            =   9.75
  17.          Charset         =   0
  18.          Weight          =   400
  19.          Underline       =   0   'False
  20.          Italic          =   0   'False
  21.          Strikethrough   =   0   'False
  22.       EndProperty
  23.       Height          =   2040
  24.       Left            =   3540
  25.       Locked          =   -1  'True
  26.       MultiLine       =   -1  'True
  27.       ScrollBars      =   2  'Vertical
  28.       TabIndex        =   5
  29.       Top             =   3990
  30.       Width           =   3930
  31.    End
  32.    Begin VB.ListBox QryList 
  33.       BeginProperty Font 
  34.          Name            =   "MS Sans Serif"
  35.          Size            =   9.75
  36.          Charset         =   0
  37.          Weight          =   400
  38.          Underline       =   0   'False
  39.          Italic          =   0   'False
  40.          Strikethrough   =   0   'False
  41.       EndProperty
  42.       Height          =   2010
  43.       Left            =   165
  44.       TabIndex        =   4
  45.       Top             =   4005
  46.       Width           =   3090
  47.    End
  48.    Begin VB.CommandButton Command1 
  49.       Caption         =   "Open Database"
  50.       BeginProperty Font 
  51.          Name            =   "MS Sans Serif"
  52.          Size            =   9.75
  53.          Charset         =   0
  54.          Weight          =   400
  55.          Underline       =   0   'False
  56.          Italic          =   0   'False
  57.          Strikethrough   =   0   'False
  58.       EndProperty
  59.       Height          =   375
  60.       Left            =   165
  61.       TabIndex        =   3
  62.       Top             =   165
  63.       Width           =   1755
  64.    End
  65.    Begin MSComDlg.CommonDialog CommonDialog1 
  66.       Left            =   6780
  67.       Top             =   600
  68.       _ExtentX        =   847
  69.       _ExtentY        =   847
  70.       _Version        =   327680
  71.       FontSize        =   1.17491e-38
  72.    End
  73.    Begin VB.ListBox FldList 
  74.       BeginProperty Font 
  75.          Name            =   "MS Sans Serif"
  76.          Size            =   9.75
  77.          Charset         =   0
  78.          Weight          =   400
  79.          Underline       =   0   'False
  80.          Italic          =   0   'False
  81.          Strikethrough   =   0   'False
  82.       EndProperty
  83.       Height          =   2250
  84.       Left            =   3540
  85.       TabIndex        =   1
  86.       Top             =   1095
  87.       Width           =   3930
  88.    End
  89.    Begin VB.ListBox TblList 
  90.       BeginProperty Font 
  91.          Name            =   "MS Sans Serif"
  92.          Size            =   9.75
  93.          Charset         =   0
  94.          Weight          =   400
  95.          Underline       =   0   'False
  96.          Italic          =   0   'False
  97.          Strikethrough   =   0   'False
  98.       EndProperty
  99.       Height          =   2250
  100.       Left            =   165
  101.       TabIndex        =   0
  102.       Top             =   1110
  103.       Width           =   3090
  104.    End
  105.    Begin VB.Label lblFields 
  106.       Caption         =   "Selected Table's Fields"
  107.       BeginProperty Font 
  108.          Name            =   "MS Sans Serif"
  109.          Size            =   9.75
  110.          Charset         =   0
  111.          Weight          =   700
  112.          Underline       =   0   'False
  113.          Italic          =   0   'False
  114.          Strikethrough   =   0   'False
  115.       EndProperty
  116.       Height          =   270
  117.       Left            =   3540
  118.       TabIndex        =   9
  119.       Top             =   765
  120.       Width           =   2940
  121.    End
  122.    Begin VB.Label lblTables 
  123.       Caption         =   "Tables"
  124.       BeginProperty Font 
  125.          Name            =   "MS Sans Serif"
  126.          Size            =   9.75
  127.          Charset         =   0
  128.          Weight          =   700
  129.          Underline       =   0   'False
  130.          Italic          =   0   'False
  131.          Strikethrough   =   0   'False
  132.       EndProperty
  133.       Height          =   270
  134.       Left            =   165
  135.       TabIndex        =   8
  136.       Top             =   720
  137.       Width           =   1755
  138.    End
  139.    Begin VB.Label lblQuery 
  140.       Caption         =   "Selected Query Definition"
  141.       BeginProperty Font 
  142.          Name            =   "MS Sans Serif"
  143.          Size            =   9.75
  144.          Charset         =   0
  145.          Weight          =   700
  146.          Underline       =   0   'False
  147.          Italic          =   0   'False
  148.          Strikethrough   =   0   'False
  149.       EndProperty
  150.       Height          =   300
  151.       Left            =   3540
  152.       TabIndex        =   7
  153.       Top             =   3645
  154.       Width           =   3510
  155.    End
  156.    Begin VB.Label lblQueries 
  157.       Caption         =   "Queries"
  158.       BeginProperty Font 
  159.          Name            =   "MS Sans Serif"
  160.          Size            =   9.75
  161.          Charset         =   0
  162.          Weight          =   700
  163.          Underline       =   0   'False
  164.          Italic          =   0   'False
  165.          Strikethrough   =   0   'False
  166.       EndProperty
  167.       Height          =   300
  168.       Left            =   165
  169.       TabIndex        =   6
  170.       Top             =   3585
  171.       Width           =   1890
  172.    End
  173.    Begin VB.Label Label1 
  174.       BorderStyle     =   1  'Fixed Single
  175.       BeginProperty Font 
  176.          Name            =   "MS Sans Serif"
  177.          Size            =   9.75
  178.          Charset         =   0
  179.          Weight          =   700
  180.          Underline       =   0   'False
  181.          Italic          =   0   'False
  182.          Strikethrough   =   0   'False
  183.       EndProperty
  184.       Height          =   375
  185.       Left            =   2220
  186.       TabIndex        =   2
  187.       Top             =   165
  188.       Width           =   5235
  189.    End
  190. Attribute VB_Name = "Form1"
  191. Attribute VB_GlobalNameSpace = False
  192. Attribute VB_Creatable = False
  193. Attribute VB_PredeclaredId = True
  194. Attribute VB_Exposed = False
  195. Option Explicit
  196. Dim DB As Database
  197. Private Sub Command1_Click()
  198. On Error GoTo NoDatabase
  199.     CommonDialog1.CancelError = True
  200.     CommonDialog1.Filter = "Databases|*.mdb"
  201.     CommonDialog1.ShowOpen
  202. ' Open the database
  203.     If CommonDialog1.filename <> "" Then
  204.         Set DB = OpenDatabase(CommonDialog1.filename)
  205.         Label1.Caption = CommonDialog1.filename
  206.     End If
  207. ' Clear the ListBox controls
  208.     FldList.Clear
  209.     TblList.Clear
  210. Dim tbl As TableDef
  211. Dim idx As Index
  212. Dim TName As String
  213. Debug.Print "There are " & DB.TableDefs.Count & " tables in the database"
  214. ' Process each table
  215.     For Each tbl In DB.TableDefs
  216.         ' EXCLUDE SYSTEM TABLES
  217.         If Left(tbl.Name, 4) <> "MSys" And Left(tbl.Name, 4) <> "USys" Then
  218.             TblList.AddItem tbl.Name
  219. ' For each table, process the table's indices
  220.             For Each idx In tbl.Indexes
  221.                 TblList.AddItem "  " & idx.Name
  222.             Next
  223.         End If
  224.     Next
  225. Dim qry As QueryDef
  226. Debug.Print "There are " & DB.QueryDefs.Count & " queries in the database"
  227. ' Process each stored query
  228.     For Each qry In DB.QueryDefs
  229.         QryList.AddItem qry.Name
  230.     Next
  231. NoDatabase:
  232. End Sub
  233. Private Sub QryList_Click()
  234. Dim qry As QueryDef
  235.     txtSQL.Text = DB.QueryDefs(QryList.ListIndex).SQL
  236.         
  237. End Sub
  238. Private Sub TblList_Click()
  239. Dim fld As Field
  240. Dim idx As Index
  241.     If Left(TblList.Text, 2) = "  " Then Exit Sub
  242.     FldList.Clear
  243.     For Each fld In DB.TableDefs(TblList.Text).Fields
  244.         FldList.AddItem fld.Name
  245.     Next
  246. End Sub
  247.