home *** CD-ROM | disk | FTP | other *** search
/ Master 95 #1 / MASTER95_1.iso / microsof / vbasic4 / vb4-6.cab / tblstru.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-26  |  24.9 KB  |  825 lines

  1. VERSION 4.00
  2. Begin VB.Form frmTblStruct 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Table Structure"
  5.    ClientHeight    =   6135
  6.    ClientLeft      =   1560
  7.    ClientTop       =   945
  8.    ClientWidth     =   7680
  9.    Height          =   6540
  10.    Icon            =   "TBLSTRU.frx":0000
  11.    Left            =   1500
  12.    LinkTopic       =   "Form1"
  13.    LockControls    =   -1  'True
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   6135
  17.    ScaleWidth      =   7680
  18.    Top             =   600
  19.    Width           =   7800
  20.    Begin VB.PictureBox picFieldProps 
  21.       Appearance      =   0  'Flat
  22.       BorderStyle     =   0  'None
  23.       Enabled         =   0   'False
  24.       ForeColor       =   &H80000008&
  25.       Height          =   615
  26.       Left            =   3120
  27.       ScaleHeight     =   615
  28.       ScaleWidth      =   4455
  29.       TabIndex        =   40
  30.       Top             =   4440
  31.       Width           =   4455
  32.       Begin VB.CheckBox chkUnique 
  33.          Caption         =   "Unique"
  34.          Height          =   255
  35.          Left            =   1560
  36.          TabIndex        =   45
  37.          TabStop         =   0   'False
  38.          Top             =   0
  39.          Width           =   1230
  40.       End
  41.       Begin VB.CheckBox chkRequiredInd 
  42.          Caption         =   "Required"
  43.          Height          =   255
  44.          Left            =   120
  45.          TabIndex        =   44
  46.          TabStop         =   0   'False
  47.          Top             =   360
  48.          Width           =   1230
  49.       End
  50.       Begin VB.CheckBox chkIgnoreNull 
  51.          Caption         =   "IgnoreNull"
  52.          Height          =   255
  53.          Left            =   1560
  54.          TabIndex        =   43
  55.          TabStop         =   0   'False
  56.          Top             =   360
  57.          Width           =   1230
  58.       End
  59.       Begin VB.CheckBox chkPrimary 
  60.          Caption         =   "Primary"
  61.          Height          =   255
  62.          Left            =   120
  63.          TabIndex        =   42
  64.          TabStop         =   0   'False
  65.          Top             =   0
  66.          Width           =   1230
  67.       End
  68.       Begin VB.CheckBox chkForeign 
  69.          Caption         =   "Foreign"
  70.          Height          =   255
  71.          Left            =   3120
  72.          TabIndex        =   41
  73.          TabStop         =   0   'False
  74.          Top             =   0
  75.          Width           =   1230
  76.       End
  77.    End
  78.    Begin VB.PictureBox picFieldProps2 
  79.       Appearance      =   0  'Flat
  80.       BorderStyle     =   0  'None
  81.       ForeColor       =   &H80000008&
  82.       Height          =   1815
  83.       Left            =   4560
  84.       ScaleHeight     =   1815
  85.       ScaleWidth      =   3015
  86.       TabIndex        =   38
  87.       Top             =   1920
  88.       Width           =   3015
  89.       Begin VB.CheckBox chkRequired 
  90.          Caption         =   "Required"
  91.          Height          =   255
  92.          Left            =   1200
  93.          TabIndex        =   5
  94.          Top             =   360
  95.          Width           =   1215
  96.       End
  97.       Begin VB.CheckBox chkAllowZeroLen 
  98.          Caption         =   "AllowZeroLength"
  99.          Height          =   255
  100.          Left            =   1200
  101.          TabIndex        =   3
  102.          Top             =   0
  103.          Width           =   1695
  104.       End
  105.       Begin VB.TextBox txtOrdinalPos 
  106.          Height          =   285
  107.          Left            =   0
  108.          TabIndex        =   4
  109.          Top             =   360
  110.          Width           =   1095
  111.       End
  112.       Begin VB.TextBox txtValidationText 
  113.          Height          =   285
  114.          Left            =   0
  115.          TabIndex        =   6
  116.          Top             =   720
  117.          Width           =   2895
  118.       End
  119.       Begin VB.TextBox txtValidationRule 
  120.          Height          =   285
  121.          Left            =   0
  122.          TabIndex        =   7
  123.          Top             =   1080
  124.          Width           =   2895
  125.       End
  126.       Begin VB.TextBox txtDefaultValue 
  127.          Height          =   285
  128.          Left            =   0
  129.          TabIndex        =   8
  130.          Top             =   1440
  131.          Width           =   2895
  132.       End
  133.    End
  134.    Begin VB.PictureBox picFieldProps1 
  135.       Appearance      =   0  'Flat
  136.       BorderStyle     =   0  'None
  137.       Enabled         =   0   'False
  138.       ForeColor       =   &H80000008&
  139.       Height          =   1095
  140.       Left            =   4560
  141.       ScaleHeight     =   1095
  142.       ScaleWidth      =   3015
  143.       TabIndex        =   32
  144.       Top             =   840
  145.       Width           =   3015
  146.       Begin VB.TextBox txtCollatingOrder 
  147.          Height          =   285
  148.          Left            =   0
  149.          TabIndex        =   39
  150.          TabStop         =   0   'False
  151.          Top             =   720
  152.          Width           =   1095
  153.       End
  154.       Begin VB.CheckBox chkAutoInc 
  155.          Caption         =   "AutoIncrement"
  156.          Height          =   255
  157.          Left            =   1200
  158.          TabIndex        =   37
  159.          TabStop         =   0   'False
  160.          Top             =   720
  161.          Width           =   1400
  162.       End
  163.       Begin VB.CheckBox chkVariable 
  164.          Caption         =   "VariableLength"
  165.          Height          =   255
  166.          Left            =   1200
  167.          TabIndex        =   36
  168.          TabStop         =   0   'False
  169.          Top             =   360
  170.          Width           =   1400
  171.       End
  172.       Begin VB.CheckBox chkFixedField 
  173.          Caption         =   "FixedLength"
  174.          Height          =   255
  175.          Left            =   1200
  176.          TabIndex        =   35
  177.          TabStop         =   0   'False
  178.          Top             =   0
  179.          Width           =   1400
  180.       End
  181.       Begin VB.TextBox txtFieldSize 
  182.          Height          =   285
  183.          Left            =   0
  184.          TabIndex        =   34
  185.          TabStop         =   0   'False
  186.          Top             =   360
  187.          Width           =   1095
  188.       End
  189.       Begin VB.ComboBox cboFieldType 
  190.          Height          =   315
  191.          ItemData        =   "TBLSTRU.frx":030A
  192.          Left            =   0
  193.          List            =   "TBLSTRU.frx":032F
  194.          Style           =   1  'Simple Combo
  195.          TabIndex        =   33
  196.          TabStop         =   0   'False
  197.          Text            =   "cboFieldType"
  198.          Top             =   0
  199.          Width           =   1095
  200.       End
  201.    End
  202.    Begin VB.TextBox txtIndexName 
  203.       Height          =   285
  204.       Left            =   4680
  205.       TabIndex        =   12
  206.       Top             =   4080
  207.       Width           =   2895
  208.    End
  209.    Begin VB.TextBox txtFieldName 
  210.       Height          =   285
  211.       Left            =   4560
  212.       TabIndex        =   2
  213.       Top             =   480
  214.       Width           =   2895
  215.    End
  216.    Begin VB.TextBox txtFields 
  217.       Height          =   285
  218.       Left            =   3960
  219.       TabIndex        =   18
  220.       TabStop         =   0   'False
  221.       Top             =   5160
  222.       Width           =   3615
  223.    End
  224.    Begin VB.ListBox lstIndexes 
  225.       Height          =   645
  226.       Left            =   120
  227.       TabIndex        =   11
  228.       Top             =   4320
  229.       Width           =   2895
  230.    End
  231.    Begin VB.CommandButton cmdAddTable 
  232.       Caption         =   "&Build the Table"
  233.       Enabled         =   0   'False
  234.       Height          =   375
  235.       HelpContextID   =   2016147
  236.       Left            =   240
  237.       TabIndex        =   15
  238.       Top             =   5640
  239.       Visible         =   0   'False
  240.       Width           =   2295
  241.    End
  242.    Begin VB.CommandButton cmdClose 
  243.       Cancel          =   -1  'True
  244.       Caption         =   "&Close"
  245.       Height          =   375
  246.       Left            =   2760
  247.       TabIndex        =   16
  248.       Top             =   5640
  249.       Width           =   2175
  250.    End
  251.    Begin VB.CommandButton cmdPrint 
  252.       Caption         =   "&Print Structure"
  253.       Height          =   375
  254.       Left            =   5160
  255.       TabIndex        =   17
  256.       Top             =   5640
  257.       Visible         =   0   'False
  258.       Width           =   2295
  259.    End
  260.    Begin VB.CommandButton cmdRemoveIndex 
  261.       Caption         =   "Re&move Index"
  262.       Height          =   375
  263.       Left            =   1560
  264.       TabIndex        =   14
  265.       Top             =   5160
  266.       Width           =   1440
  267.    End
  268.    Begin VB.CommandButton cmdAddIndex 
  269.       Caption         =   "Add &Index"
  270.       Height          =   375
  271.       Left            =   120
  272.       TabIndex        =   13
  273.       Top             =   5160
  274.       Width           =   1440
  275.    End
  276.    Begin VB.ListBox lstFields 
  277.       Height          =   2400
  278.       Left            =   120
  279.       TabIndex        =   1
  280.       Top             =   720
  281.       Width           =   2895
  282.    End
  283.    Begin VB.CommandButton cmdAddField 
  284.       Caption         =   "&Add Field"
  285.       Height          =   375
  286.       Left            =   120
  287.       TabIndex        =   9
  288.       Top             =   3360
  289.       Width           =   1440
  290.    End
  291.    Begin VB.CommandButton cmdRemoveField 
  292.       Caption         =   "&Remove Field"
  293.       Height          =   375
  294.       Left            =   1545
  295.       TabIndex        =   10
  296.       Top             =   3360
  297.       Width           =   1440
  298.    End
  299.    Begin VB.TextBox txtTableName 
  300.       BackColor       =   &H00FFFFFF&
  301.       Height          =   285
  302.       Left            =   1920
  303.       TabIndex        =   0
  304.       Top             =   120
  305.       Width           =   3135
  306.    End
  307.    Begin VB.Label lblLabels 
  308.       AutoSize        =   -1  'True
  309.       Caption         =   "Name: "
  310.       Height          =   195
  311.       Index           =   21
  312.       Left            =   3240
  313.       TabIndex        =   31
  314.       Top             =   4080
  315.       Width           =   510
  316.    End
  317.    Begin VB.Label lblLabels 
  318.       AutoSize        =   -1  'True
  319.       Caption         =   "Name: "
  320.       Height          =   195
  321.       Index           =   20
  322.       Left            =   3120
  323.       TabIndex        =   30
  324.       Top             =   480
  325.       Width           =   510
  326.    End
  327.    Begin VB.Label lblLabels 
  328.       AutoSize        =   -1  'True
  329.       Caption         =   "Fields: "
  330.       Height          =   195
  331.       Index           =   19
  332.       Left            =   3240
  333.       TabIndex        =   29
  334.       Top             =   5160
  335.       Width           =   495
  336.    End
  337.    Begin VB.Label lblLabels 
  338.       AutoSize        =   -1  'True
  339.       Caption         =   "DefaultValue: "
  340.       Height          =   195
  341.       Index           =   10
  342.       Left            =   3120
  343.       TabIndex        =   28
  344.       Top             =   3435
  345.       Width           =   1005
  346.    End
  347.    Begin VB.Label lblLabels 
  348.       AutoSize        =   -1  'True
  349.       Caption         =   "ValidationRule: "
  350.       Height          =   195
  351.       Index           =   9
  352.       Left            =   3120
  353.       TabIndex        =   27
  354.       Top             =   3075
  355.       Width           =   1110
  356.    End
  357.    Begin VB.Label lblLabels 
  358.       AutoSize        =   -1  'True
  359.       Caption         =   "ValidationText: "
  360.       Height          =   195
  361.       Index           =   8
  362.       Left            =   3120
  363.       TabIndex        =   26
  364.       Top             =   2715
  365.       Width           =   1095
  366.    End
  367.    Begin VB.Label lblLabels 
  368.       AutoSize        =   -1  'True
  369.       Caption         =   "OrdinalPosition: "
  370.       Height          =   195
  371.       Index           =   7
  372.       Left            =   3120
  373.       TabIndex        =   25
  374.       Top             =   2355
  375.       Width           =   1140
  376.    End
  377.    Begin VB.Label lblLabels 
  378.       AutoSize        =   -1  'True
  379.       Caption         =   "Size: "
  380.       Height          =   195
  381.       Index           =   5
  382.       Left            =   3120
  383.       TabIndex        =   24
  384.       Top             =   1200
  385.       Width           =   390
  386.    End
  387.    Begin VB.Label lblLabels 
  388.       AutoSize        =   -1  'True
  389.       Caption         =   "Type: "
  390.       Height          =   195
  391.       Index           =   4
  392.       Left            =   3120
  393.       TabIndex        =   23
  394.       Top             =   840
  395.       Width           =   450
  396.    End
  397.    Begin VB.Line Line1 
  398.       BorderWidth     =   3
  399.       X1              =   120
  400.       X2              =   7560
  401.       Y1              =   3840
  402.       Y2              =   3840
  403.    End
  404.    Begin VB.Label lblLabels 
  405.       AutoSize        =   -1  'True
  406.       Caption         =   "CollatingOrder: "
  407.       Height          =   195
  408.       Index           =   0
  409.       Left            =   3120
  410.       TabIndex        =   22
  411.       Top             =   1560
  412.       Width           =   1080
  413.    End
  414.    Begin VB.Label lblLabels 
  415.       AutoSize        =   -1  'True
  416.       Caption         =   " Index List: "
  417.       Height          =   195
  418.       Index           =   1
  419.       Left            =   120
  420.       TabIndex        =   21
  421.       Top             =   4080
  422.       Width           =   810
  423.    End
  424.    Begin VB.Label lblLabels 
  425.       AutoSize        =   -1  'True
  426.       Caption         =   "Fields: "
  427.       Height          =   195
  428.       Index           =   2
  429.       Left            =   120
  430.       TabIndex        =   20
  431.       Top             =   480
  432.       Width           =   495
  433.    End
  434.    Begin VB.Label lblLabels 
  435.       AutoSize        =   -1  'True
  436.       Caption         =   "Table Name: "
  437.       Height          =   195
  438.       Index           =   3
  439.       Left            =   120
  440.       TabIndex        =   19
  441.       Top             =   120
  442.       Width           =   960
  443.    End
  444. Attribute VB_Name = "frmTblStruct"
  445. Attribute VB_Creatable = False
  446. Attribute VB_Exposed = False
  447. Option Explicit
  448. Dim msCurrField As String
  449. Dim mfldCurrFld As Field
  450. Dim msCurrIndex As String
  451. Dim mindCurrInd As Index
  452. Dim mnFldCount As Integer
  453. Dim mnIndCount As Integer
  454. Sub cboFieldType_Change()
  455.   If mfldCurrFld.Type < 9 Then
  456.     cboFieldType.ListIndex = mfldCurrFld.Type - 1
  457.   Else
  458.     cboFieldType.ListIndex = mfldCurrFld.Type - 2
  459.   End If
  460. End Sub
  461. Sub cboFieldType_Click()
  462.   If mfldCurrFld.Type < 9 Then
  463.     cboFieldType.ListIndex = mfldCurrFld.Type - 1
  464.   Else
  465.     cboFieldType.ListIndex = mfldCurrFld.Type - 2
  466.   End If
  467. End Sub
  468. Private Sub chkAllowZeroLen_Click()
  469.   On Error GoTo AZErr
  470.   mfldCurrFld.AllowZeroLength = IIf(chkAllowZeroLen.Value = 1, True, False)
  471.   Exit Sub
  472. AZErr:
  473.   ShowError
  474.   Exit Sub
  475. End Sub
  476. Private Sub chkRequired_Click()
  477.   On Error GoTo RQErr
  478.   mfldCurrFld.Required = IIf(chkRequired.Value = 1, True, False)
  479.   Exit Sub
  480. RQErr:
  481.   ShowError
  482.   Exit Sub
  483. End Sub
  484. Private Sub cmdAddField_Click()
  485.   MsgBar "Enter New Field Parameters, Press 'Close' when finished", False
  486.   frmAddField.Show vbModal
  487.   MsgBar gsNULL_STR, False
  488. End Sub
  489. Private Sub cmdAddIndex_Click()
  490.   MsgBar "Enter New Index Parameters, Press 'Close' when finished", False
  491.   frmAddIndex.Show vbModal
  492.   MsgBar gsNULL_STR, False
  493. End Sub
  494. Private Sub cmdAddTable_Click()
  495.   On Error GoTo ATErr
  496.   Dim i As Integer
  497.   If DupeTableName(gtdfTableDef.Name) = True Then
  498.     Screen.MousePointer = vbDefault
  499.     Exit Sub
  500.   End If
  501.   SetHourglass
  502.   MsgBar "Adding the New Table to the Database", True
  503.   'append the tabledef
  504.   gdbCurrentDB.TableDefs.Append gtdfTableDef
  505.   RefreshTables frmTables.lstTables, True
  506.   Screen.MousePointer = vbDefault
  507.   MsgBar gsNULL_STR, False
  508.   Unload Me
  509.   Exit Sub
  510. ATErr:
  511.   ShowError
  512.   Exit Sub
  513. End Sub
  514. Private Sub cmdClose_Click()
  515.   Unload Me
  516.   MsgBar gsNULL_STR, False
  517. End Sub
  518. Sub lstFields_Click()
  519.   On Error GoTo FErr
  520.   If lstFields.ListIndex = -1 Then Exit Sub
  521.   msCurrField = lstFields.Text
  522.   Set mfldCurrFld = gtdfTableDef.Fields(msCurrField)
  523.   txtFieldName.Text = mfldCurrFld.Name
  524.   txtOrdinalPos.Text = mfldCurrFld.OrdinalPosition
  525.   If mfldCurrFld.Type < 9 Then
  526.     cboFieldType.ListIndex = mfldCurrFld.Type - 1
  527.   Else
  528.     cboFieldType.ListIndex = mfldCurrFld.Type - 2
  529.   End If
  530.   txtFieldSize.Text = mfldCurrFld.Size
  531.   txtCollatingOrder.Text = mfldCurrFld.CollatingOrder
  532.   chkFixedField.Value = IIf((mfldCurrFld.Attributes And dbFixedField) = dbFixedField, 1, 0)
  533.   chkVariable.Value = IIf((mfldCurrFld.Attributes And dbVariableField) = dbVariableField, 1, 0)
  534.   chkAutoInc.Value = IIf((mfldCurrFld.Attributes And dbAutoIncrField) = dbAutoIncrField, 1, 0)
  535.   If gsDataType = gsJETMDB Then
  536.     txtValidationText.Text = mfldCurrFld.ValidationText
  537.     txtValidationRule.Text = mfldCurrFld.ValidationRule
  538.     txtDefaultValue.Text = mfldCurrFld.DefaultValue
  539.     chkRequired.Value = IIf(mfldCurrFld.Required = True, 1, 0)
  540.     chkAllowZeroLen.Value = IIf(mfldCurrFld.AllowZeroLength = True, 1, 0)
  541.   End If
  542.   Exit Sub
  543. FErr:
  544.   ShowError
  545.   Exit Sub
  546. End Sub
  547. Sub lstIndexes_Click()
  548.   On Error GoTo IErr
  549.   If lstIndexes.ListIndex = -1 Then Exit Sub
  550.   msCurrIndex = lstIndexes.Text
  551.   Set mindCurrInd = gtdfTableDef.Indexes(msCurrIndex)
  552.   txtIndexName.Text = mindCurrInd.Name
  553.   txtFields.Text = mindCurrInd.Fields
  554.   chkRequiredInd.Value = IIf(mindCurrInd.Required = True, 1, 0)
  555.   chkUnique.Value = IIf(mindCurrInd.UNIQUE = True, 1, 0)
  556.   chkIgnoreNull.Value = IIf(mindCurrInd.IgnoreNulls = True, 1, 0)
  557.   If gsDataType = gsJETMDB Then
  558.     chkPrimary.Value = IIf(mindCurrInd.PRIMARY = True, 1, 0)
  559.     chkForeign.Value = IIf(mindCurrInd.FOREIGN = True, 1, 0)
  560.   End If
  561.   Exit Sub
  562. IErr:
  563.   ShowError
  564.   Exit Sub
  565. End Sub
  566. Private Sub txtCollatingOrder_LostFocus()
  567.   'reset it because it is readonly
  568.   txtCollatingOrder.Text = mfldCurrFld.CollatingOrder
  569. End Sub
  570. Private Sub txtDefaultValue_LostFocus()
  571.   On Error GoTo DVErr
  572.   If mfldCurrFld.DefaultValue <> txtDefaultValue.Text Then
  573.     If Len(txtDefaultValue.Text) > 0 Then
  574.       mfldCurrFld.DefaultValue = txtDefaultValue.Text
  575.     End If
  576.   End If
  577.   Exit Sub
  578. DVErr:
  579.   ShowError
  580.   Exit Sub
  581. End Sub
  582. Private Sub txtFieldName_LostFocus()
  583.   On Error GoTo FNErr
  584.   Dim i As Integer
  585.   'change the name if the user changed it
  586.   If mfldCurrFld.Name <> txtFieldName.Text Then
  587.     If Len(txtFieldName.Text) > 0 Then
  588.       For i = 0 To lstFields.ListCount - 1
  589.         If lstFields.List(i) = mfldCurrFld.Name Then
  590.           lstFields.RemoveItem i
  591.           lstFields.AddItem txtFieldName.Text, i
  592.           Exit For
  593.         End If
  594.       Next
  595.       mfldCurrFld.Name = txtFieldName.Text
  596.     End If
  597.   End If
  598.   Exit Sub
  599. FNErr:
  600.   ShowError
  601.   Exit Sub
  602. End Sub
  603. Sub txtFields_LostFocus()
  604.   'reset it because it is readonly
  605.   txtFields.Text = mindCurrInd.Fields
  606. End Sub
  607. Private Sub txtFieldSize_LostFocus()
  608.   'reset it because it is readonly
  609.   txtFieldSize.Text = mfldCurrFld.Size
  610. End Sub
  611. Private Sub txtIndexName_LostFocus()
  612.   On Error GoTo IDNErr
  613.   Dim i As Integer
  614.   'change the name if the user changed it
  615.   If mindCurrInd.Name <> txtIndexName.Text Then
  616.     If Len(txtIndexName.Text) > 0 And gsDataType = gsJETMDB Then
  617.       For i = 0 To lstIndexes.ListCount - 1
  618.         If lstIndexes.List(i) = mindCurrInd.Name Then
  619.           lstIndexes.RemoveItem i
  620.           lstIndexes.AddItem txtIndexName.Text, i
  621.           Exit For
  622.         End If
  623.       Next
  624.       mindCurrInd.Name = txtIndexName.Text
  625.     End If
  626.   End If
  627.   Exit Sub
  628. IDNErr:
  629.   ShowError
  630.   Exit Sub
  631. End Sub
  632. Private Sub txtOrdinalPos_LostFocus()
  633.   On Error GoTo OPErr
  634.   If mfldCurrFld.OrdinalPosition <> txtOrdinalPos.Text Then
  635.     If Len(txtFieldName.Text) > 0 And gsDataType = gsJETMDB Then
  636.       mfldCurrFld.OrdinalPosition = txtOrdinalPos.Text
  637.     End If
  638.   End If
  639.   Exit Sub
  640. OPErr:
  641.   ShowError
  642.   Exit Sub
  643. End Sub
  644. Private Sub txtTableName_Change()
  645.   If gbAddTableFlag = True Then
  646.     If Len(txtTableName.Text) > 0 And lstFields.ListCount > 0 Then
  647.       cmdAddTable.Enabled = True
  648.     Else
  649.       cmdAddTable.Enabled = False
  650.     End If
  651.     gtdfTableDef.Name = txtTableName.Text
  652.   End If
  653. End Sub
  654. Private Sub txtTableName_LostFocus()
  655.   On Error GoTo TBNErr
  656.   Dim i As Integer
  657.   'change the name if the user changed it
  658.   If gtdfTableDef.Name <> txtTableName.Text Then
  659.     If Len(txtTableName.Text) > 0 And gsDataType = gsJETMDB Then
  660.       'find and rename the entry in the tables form list
  661.       For i = 0 To frmTables.lstTables.ListCount - 1
  662.         If frmTables.lstTables.List(i) = gtdfTableDef.Name Then
  663.           frmTables.lstTables.RemoveItem i
  664.           frmTables.lstTables.AddItem txtTableName.Text, i
  665.           Exit For
  666.         End If
  667.       Next
  668.       gtdfTableDef.Name = txtTableName.Text
  669.     End If
  670.   End If
  671.   Exit Sub
  672. TBNErr:
  673.   ShowError
  674.   Exit Sub
  675. End Sub
  676. Private Sub txtTableName_KeyPress(KeyAscii As Integer)
  677.   If txtTableName.TabStop = False Then
  678.     KeyAscii = 0   'throw away the key
  679.   End If
  680. End Sub
  681. Private Sub cmdRemoveIndex_Click()
  682.   On Error GoTo DELErr
  683.   If lstIndexes.ListIndex < 0 Then Exit Sub
  684.   If MsgBox("Delete """ & lstIndexes.Text & """ index?", gnMSGBOX_TYPE) = gnMSGBOX_YES Then
  685.     If gbAddTableFlag = False Then
  686.       gtdfTableDef.Indexes.Delete lstIndexes.Text
  687.     End If
  688.     'refresh the list of indexes
  689.     lstIndexes.RemoveItem lstIndexes.ListIndex
  690.   End If
  691.   Exit Sub
  692. DELErr:
  693.   ShowError
  694.   Exit Sub
  695. End Sub
  696. Private Sub Form_Load()
  697.   On Error GoTo LoadErr
  698.   Dim fld As Field
  699.   Dim idx As Index
  700.   SetHourglass
  701.   MsgBar "Opening Design Form", True
  702.   CenterMe Me, gnMDIFORM
  703.   If gbAddTableFlag = True Then
  704.     Set gtdfTableDef = gdbCurrentDB.CreateTableDef()
  705.     mnFldCount = 0
  706.     mnIndCount = 0
  707.     cmdAddTable.Visible = True
  708.   Else
  709.     cmdPrint.Visible = True
  710.     Set gtdfTableDef = gdbCurrentDB.TableDefs(StripConnect(frmTables.lstTables.Text))
  711.     txtTableName.Text = gtdfTableDef.Name
  712.     ListItemNames gtdfTableDef.Fields, lstFields, False
  713.     mnFldCount = lstFields.ListCount
  714.     lstFields.ListIndex = 0
  715.     ListItemNames gtdfTableDef.Indexes, lstIndexes, False
  716.     mnIndCount = lstIndexes.ListCount
  717.     If mnIndCount > 0 Then lstIndexes.ListIndex = 0
  718.   End If
  719.   If gsDataType <> gsJETMDB Then
  720.     'can't change table names on non-mdbs
  721.     If gbAddTableFlag = False Then txtTableName.Locked = True
  722.     'can't remove fields on non-mdb tables
  723.     If gbAddTableFlag = False Then cmdRemoveField.Enabled = False
  724.     'disable other properties that are not changable on non-mdb tables
  725.     txtFieldName.Locked = True
  726.     picFieldProps2.Enabled = False
  727.     chkRequired.Enabled = False
  728.     chkAllowZeroLen.Enabled = False
  729.     txtIndexName.Locked = True
  730.     txtFields.Locked = True
  731.   End If
  732.   Screen.MousePointer = vbDefault
  733.   MsgBar gsNULL_STR, False
  734.   Exit Sub
  735. LoadErr:
  736.   Screen.MousePointer = vbDefault
  737.   ShowError
  738.   Unload Me
  739.   MsgBar gsNULL_STR, False
  740.   Exit Sub
  741. End Sub
  742. Private Sub cmdPrint_Click()
  743.   On Error GoTo PRTErr
  744.   'this routine simply prints the currently
  745.   'selected table's definition
  746.   Dim i As Integer
  747.   Dim sTmp As String
  748.   MsgBar "Printing Table Structure", True
  749.   Printer.Print
  750.   Printer.Print
  751.   Printer.Print
  752.   Printer.Print "Database: " & gsDBName
  753.   Printer.Print
  754.   Printer.Print
  755.   Printer.Print "Table Definition for " & txtTableName
  756.   Printer.Print
  757.   Printer.Print
  758.   Printer.Print "Fields: (Name - Type - Size)"
  759.   Printer.Print String(60, "-")
  760.   For i = 0 To lstFields.ListCount - 1
  761.     lstFields.ListIndex = i
  762.     sTmp = txtFieldName.Text & " - "
  763.     sTmp = sTmp & cboFieldType.Text & " - "
  764.     sTmp = sTmp & txtFieldSize.Text
  765.     Printer.Print sTmp
  766.   Next
  767.   Printer.Print
  768.   Printer.Print
  769.   Printer.Print "Index List (Name - Fields - Unique)"
  770.   Printer.Print String(60, "-")
  771.   For i = 0 To lstIndexes.ListCount - 1
  772.     sTmp = txtIndexName.Text & " - "
  773.     sTmp = sTmp & txtFields.Text & " - "
  774.     sTmp = sTmp & IIf(chkUnique = 1, "True", "False")
  775.     Printer.Print sTmp
  776.   Next
  777.   Printer.NewPage
  778.   Printer.EndDoc
  779.   MsgBar gsNULL_STR, False
  780.   Exit Sub
  781. PRTErr:
  782.   MsgBar gsNULL_STR, False
  783.   ShowError
  784.   Exit Sub
  785. End Sub
  786. Private Sub cmdRemoveField_Click()
  787.   On Error GoTo RFErr
  788.   If lstFields.ListIndex < 0 Then Exit Sub
  789.   If MsgBox("Remove """ & lstFields.Text & """ field?", gnMSGBOX_TYPE) = gnMSGBOX_YES Then
  790.     If gbAddTableFlag = False Then
  791.       gtdfTableDef.Fields.Delete lstFields.Text
  792.     End If
  793.     lstFields.RemoveItem lstFields.ListIndex
  794.   End If
  795.   GoTo RFEnd
  796. RFErr:
  797.   ShowError
  798.   Resume RFEnd
  799. RFEnd:
  800. End Sub
  801. Private Sub txtValidationRule_LostFocus()
  802.   On Error GoTo VRErr
  803.   If mfldCurrFld.ValidationRule <> txtValidationRule.Text Then
  804.     If Len(txtValidationRule.Text) > 0 And gsDataType = gsJETMDB Then
  805.       mfldCurrFld.ValidationRule = txtValidationRule.Text
  806.     End If
  807.   End If
  808.   Exit Sub
  809. VRErr:
  810.   ShowError
  811.   Exit Sub
  812. End Sub
  813. Private Sub txtValidationText_LostFocus()
  814.   On Error GoTo VTErr
  815.   If mfldCurrFld.ValidationText <> txtValidationText.Text Then
  816.     If Len(txtValidationText.Text) > 0 And gsDataType = gsJETMDB Then
  817.       mfldCurrFld.ValidationText = txtValidationText.Text
  818.     End If
  819.   End If
  820.   Exit Sub
  821. VTErr:
  822.   ShowError
  823.   Exit Sub
  824. End Sub
  825.