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

  1. VERSION 4.00
  2. Begin VB.Form frmAddIndex 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Add Index"
  5.    ClientHeight    =   3495
  6.    ClientLeft      =   2970
  7.    ClientTop       =   1665
  8.    ClientWidth     =   5400
  9.    ForeColor       =   &H00000000&
  10.    Height          =   3900
  11.    HelpContextID   =   2016118
  12.    Icon            =   "ADDINDEX.frx":0000
  13.    Left            =   2910
  14.    LinkTopic       =   "Form1"
  15.    LockControls    =   -1  'True
  16.    MaxButton       =   0   'False
  17.    MinButton       =   0   'False
  18.    ScaleHeight     =   3476.108
  19.    ScaleMode       =   0  'User
  20.    ScaleWidth      =   5429.725
  21.    Top             =   1320
  22.    Width           =   5520
  23.    Begin VB.CheckBox chkIgnoreNulls 
  24.       Caption         =   "IgnoreNulls"
  25.       Height          =   255
  26.       Left            =   3120
  27.       TabIndex        =   5
  28.       Top             =   1320
  29.       Width           =   2188
  30.    End
  31.    Begin VB.CheckBox chkPrimary 
  32.       Caption         =   "Primary"
  33.       Height          =   255
  34.       Left            =   3120
  35.       TabIndex        =   3
  36.       Top             =   360
  37.       Value           =   1  'Checked
  38.       Width           =   2188
  39.    End
  40.    Begin VB.TextBox txtIndexName 
  41.       BackColor       =   &H00FFFFFF&
  42.       Height          =   285
  43.       Left            =   120
  44.       TabIndex        =   0
  45.       Top             =   360
  46.       Width           =   2775
  47.    End
  48.    Begin VB.TextBox txtFields 
  49.       BackColor       =   &H00FFFFFF&
  50.       Height          =   525
  51.       Left            =   120
  52.       MultiLine       =   -1  'True
  53.       ScrollBars      =   2  'Vertical
  54.       TabIndex        =   1
  55.       Top             =   960
  56.       Width           =   2775
  57.    End
  58.    Begin VB.ListBox lstFields 
  59.       BackColor       =   &H00FFFFFF&
  60.       Height          =   1590
  61.       Left            =   120
  62.       Sorted          =   -1  'True
  63.       TabIndex        =   2
  64.       Top             =   1800
  65.       Width           =   2775
  66.    End
  67.    Begin VB.CheckBox chkUnique 
  68.       Caption         =   "Unique"
  69.       Height          =   252
  70.       Left            =   3120
  71.       TabIndex        =   4
  72.       Top             =   840
  73.       Value           =   1  'Checked
  74.       Width           =   2188
  75.    End
  76.    Begin VB.CommandButton cmdOK 
  77.       Caption         =   "&OK"
  78.       Default         =   -1  'True
  79.       Enabled         =   0   'False
  80.       Height          =   375
  81.       Left            =   3240
  82.       TabIndex        =   6
  83.       Top             =   2400
  84.       Width           =   1815
  85.    End
  86.    Begin VB.CommandButton cmdClose 
  87.       Cancel          =   -1  'True
  88.       Caption         =   "&Close"
  89.       Height          =   375
  90.       Left            =   3240
  91.       TabIndex        =   7
  92.       Top             =   2880
  93.       Width           =   1815
  94.    End
  95.    Begin VB.Label lblLabels 
  96.       AutoSize        =   -1  'True
  97.       Caption         =   "Available Fields: "
  98.       Height          =   195
  99.       Index           =   0
  100.       Left            =   120
  101.       TabIndex        =   10
  102.       Top             =   1560
  103.       Width           =   1185
  104.    End
  105.    Begin VB.Label lblLabels 
  106.       AutoSize        =   -1  'True
  107.       Caption         =   "Indexed  Fields:"
  108.       Height          =   195
  109.       Index           =   1
  110.       Left            =   120
  111.       TabIndex        =   9
  112.       Top             =   720
  113.       Width           =   1110
  114.    End
  115.    Begin VB.Label lblLabels 
  116.       AutoSize        =   -1  'True
  117.       Caption         =   "Name: "
  118.       Height          =   195
  119.       Index           =   2
  120.       Left            =   120
  121.       TabIndex        =   8
  122.       Top             =   120
  123.       Width           =   510
  124.    End
  125. Attribute VB_Name = "frmAddIndex"
  126. Attribute VB_Creatable = False
  127. Attribute VB_Exposed = False
  128. Option Explicit
  129. Private Sub lstFields_Click()
  130.   Dim sTmp As String
  131.   sTmp = txtFields.Text
  132.   If Len(sTmp) = 0 Then
  133.     txtFields.Text = sTmp & lstFields
  134.   Else
  135.     txtFields.Text = sTmp & ";" & lstFields
  136.   End If
  137.   txtFields.Refresh
  138. End Sub
  139. Private Sub txtFields_Change()
  140.   If Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0 Then
  141.     cmdOK.Enabled = True
  142.   Else
  143.     cmdOK.Enabled = False
  144.   End If
  145. End Sub
  146. Private Sub txtFields_LostFocus()
  147.   If Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0 Then
  148.     cmdOK.Enabled = True
  149.   Else
  150.     cmdOK.Enabled = False
  151.   End If
  152. End Sub
  153. Private Sub txtIndexName_LostFocus()
  154.   If Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0 Then
  155.     cmdOK.Enabled = True
  156.   Else
  157.     cmdOK.Enabled = False
  158.   End If
  159. End Sub
  160. Private Sub cmdClose_Click()
  161.   Unload Me
  162. End Sub
  163. Private Sub Form_Load()
  164.   Dim tblTableDef As TableDef
  165.   Dim fld As Field
  166.   Dim i As Integer
  167.   CenterMe Me, gnMDIFORM
  168.   If gbAddTableFlag = True Then
  169.     Me.Caption = Me.Caption & " to " & frmTblStruct.txtTableName
  170.     For i = 0 To frmTblStruct.lstFields.ListCount - 1
  171.       lstFields.AddItem frmTblStruct.lstFields.List(i)
  172.     Next
  173.   Else
  174.     Me.Caption = Me.Caption & " to " & StripConnect(frmTables.lstTables.Text)
  175.     Set tblTableDef = gdbCurrentDB.TableDefs(StripConnect(frmTables.lstTables.Text))
  176.     ListItemNames tblTableDef.Fields, lstFields, False
  177.   End If
  178.   If gsDataType <> gsJETMDB Then
  179.     chkPrimary.Enabled = False
  180.     chkIgnoreNulls.Enabled = False
  181.     chkPrimary.Value = vbGrayed
  182.     chkIgnoreNulls.Value = vbGrayed
  183.   End If
  184.   SetDefaults
  185. End Sub
  186. Private Sub txtIndexName_Change()
  187.   If Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0 Then
  188.     cmdOK.Enabled = True
  189.   Else
  190.     cmdOK.Enabled = False
  191.   End If
  192. End Sub
  193. Private Sub cmdOK_Click()
  194.   Dim indIndexObj As Index
  195.   Dim tblTableDefObj As TableDef
  196.   Dim sTmp As String
  197.   On Error GoTo AddIndexErr
  198.   SetHourglass
  199.   Set indIndexObj = gtdfTableDef.CreateIndex(txtIndexName.Text)
  200.   With indIndexObj
  201.     .Fields = txtFields.Text
  202.     .Unique = chkUnique.Value
  203.     If gsDataType = gsJETMDB Then
  204.       .Primary = IIf(chkPrimary.Value, True, False)
  205.       .IgnoreNulls = IIf(chkIgnoreNulls.Value = vbChecked, True, False)
  206.     End If
  207.   End With
  208.   'append the index to the global tabledef
  209.   'from the tblstruct form
  210.   gtdfTableDef.Indexes.Append indIndexObj
  211.   'add the index to the list
  212.   frmTblStruct.lstIndexes.AddItem txtIndexName.Text
  213.   'make the new item active
  214.   frmTblStruct.lstIndexes.ListIndex = frmTblStruct.lstIndexes.NewIndex
  215.   'clear the name and allow entry of another
  216.   SetDefaults
  217.   txtIndexName.SetFocus
  218.   Screen.MousePointer = vbDefault
  219.   Exit Sub
  220. AddIndexErr:
  221.   ShowError
  222.   Exit Sub
  223. End Sub
  224. Private Sub SetDefaults()
  225.   txtIndexName.Text = gsNULL_STR
  226.   If gsDataType = gsJETMDB Then
  227.     txtFields.Text = gsNULL_STR
  228.     chkUnique.Value = vbChecked
  229.   End If
  230. End Sub
  231.