home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l406 / 4.ddi / INDEXADD.FR_ / INDEXADD.bin (.txt)
Encoding:
Visual Basic Form  |  1992-10-21  |  5.1 KB  |  195 lines

  1. VERSION 2.00
  2. Begin Form fIndexAdd 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Add Index"
  5.    Height          =   3180
  6.    Left            =   3795
  7.    LinkTopic       =   "Form1"
  8.    MaxButton       =   0   'False
  9.    MinButton       =   0   'False
  10.    ScaleHeight     =   2760
  11.    ScaleMode       =   0  'User
  12.    ScaleWidth      =   4932
  13.    Top             =   3450
  14.    Width           =   5025
  15.    Begin TextBox cIndexName 
  16.       Height          =   290
  17.       Left            =   955
  18.       TabIndex        =   0
  19.       Top             =   121
  20.       Width           =   2518
  21.    End
  22.    Begin TextBox cFieldNames 
  23.       Height          =   531
  24.       Left            =   955
  25.       MultiLine       =   -1  'True
  26.       TabIndex        =   1
  27.       Top             =   483
  28.       Width           =   2518
  29.    End
  30.    Begin ListBox cFieldList 
  31.       Columns         =   2
  32.       Height          =   1590
  33.       Left            =   960
  34.       Sorted          =   -1  'True
  35.       TabIndex        =   7
  36.       Top             =   1080
  37.       Width           =   2520
  38.    End
  39.    Begin CheckBox cUniqueFlag 
  40.       Caption         =   "Unique"
  41.       Height          =   253
  42.       Left            =   3580
  43.       TabIndex        =   8
  44.       Top             =   603
  45.       Value           =   1  'Checked
  46.       Width           =   1086
  47.    End
  48.    Begin CommandButton OkayButton 
  49.       Caption         =   "&OK"
  50.       Default         =   -1  'True
  51.       Enabled         =   0   'False
  52.       Height          =   374
  53.       Left            =   3580
  54.       TabIndex        =   4
  55.       Top             =   1327
  56.       Width           =   1205
  57.    End
  58.    Begin CommandButton CloseButton 
  59.       Cancel          =   -1  'True
  60.       Caption         =   "&Close"
  61.       Height          =   374
  62.       Left            =   3580
  63.       TabIndex        =   5
  64.       Top             =   1930
  65.       Width           =   1205
  66.    End
  67.    Begin Label FieldListLabel 
  68.       Caption         =   "Fields:"
  69.       Height          =   253
  70.       Left            =   119
  71.       TabIndex        =   6
  72.       Top             =   1086
  73.       Width           =   847
  74.    End
  75.    Begin Label FieldsLabel 
  76.       Caption         =   "Indexed Fields:"
  77.       Height          =   495
  78.       Left            =   119
  79.       TabIndex        =   3
  80.       Top             =   483
  81.       Width           =   847
  82.    End
  83.    Begin Label NameLabel 
  84.       Caption         =   "Name:"
  85.       Height          =   253
  86.       Left            =   119
  87.       TabIndex        =   2
  88.       Top             =   121
  89.       Width           =   847
  90.    End
  91. Option Explicit
  92. Sub cFieldList_Click ()
  93.   Dim s As String
  94.   s = cFieldNames
  95.   If s = "" Then
  96.     cFieldNames = s + cFieldList
  97.   Else
  98.     cFieldNames = s + ";" + cFieldList
  99.   End If
  100.   cFieldNames.Refresh
  101. End Sub
  102. Sub cFieldNames_Change ()
  103.   If cIndexName <> "" And cFieldNames <> "" Then
  104.     OkayButton.Enabled = True
  105.   Else
  106.     OkayButton.Enabled = False
  107.   End If
  108. End Sub
  109. Sub cFieldNames_LostFocus ()
  110.   If cIndexName <> "" And cFieldNames <> "" Then
  111.     OkayButton.Enabled = True
  112.   Else
  113.     OkayButton.Enabled = False
  114.   End If
  115. End Sub
  116. Sub cIndexName_LostFocus ()
  117.   If cIndexName <> "" And cFieldNames <> "" Then
  118.     OkayButton.Enabled = True
  119.   Else
  120.     OkayButton.Enabled = False
  121.   End If
  122. End Sub
  123. Sub CloseButton_Click ()
  124.   Unload Me
  125. End Sub
  126. Sub Form_Load ()
  127.   Dim t As TableDef
  128.   Dim i As Integer
  129.   If gfAddTableFlag = True Then
  130.     Caption = Caption + " to " + fTblStru.cTableName
  131.     fTblStru.cFields.Col = 0
  132.     For i = 1 To fTblStru.cFields.Rows - 1
  133.       fTblStru.cFields.Row = i
  134.       cFieldList.AddItem fTblStru.cFields
  135.     Next
  136.   Else
  137.     Caption = Caption + " to " + fTables.cTableList
  138.     Set t = gCurrentDB.TableDefs(fTables.cTableList)
  139.     t.Fields.Refresh
  140.     For i = 0 To t.Fields.Count - 1
  141.       cFieldList.AddItem t.Fields(i).Name
  142.     Next
  143.   End If
  144. End Sub
  145. Sub IndexName_Change ()
  146.   If cIndexName <> "" And cFieldNames <> "" Then
  147.     OkayButton.Enabled = True
  148.   Else
  149.     OkayButton.Enabled = False
  150.   End If
  151. End Sub
  152. Sub OkayButton_Click ()
  153.   Dim i As New Index
  154.   Dim t As TableDef
  155.   Dim s As String
  156.   On Error GoTo AddIndexErr
  157.   SetHourGlass Me
  158.   i.Name = cIndexName
  159.   i.Fields = cFieldNames
  160.   i.Unique = cUniqueFlag
  161.   If gfAddTableFlag = False Then
  162.     Set t = gCurrentDB.TableDefs(fTables.cTableList)
  163.     t.Indexes.Append i
  164.   End If
  165.   fTblStru.cIndexes.Row = 1
  166.   fTblStru.cIndexes.Col = 0
  167.   If fTblStru.cIndexes <> "" Then
  168.     'add a row if the first one isn't blank
  169.     fTblStru.cIndexes.Rows = fTblStru.cIndexes.Rows + 1
  170.   End If
  171.   fTblStru.cIndexes.Row = fTblStru.cIndexes.Rows - 1
  172.   fTblStru.cIndexes.Col = 0
  173.   fTblStru.cIndexes = cIndexName
  174.   fTblStru.cIndexes.Col = 1
  175.   fTblStru.cIndexes = cFieldNames
  176.   fTblStru.cIndexes.Col = 2
  177.   If i.Unique = False Then
  178.     s = s + "False"
  179.   Else
  180.     s = s + "True"
  181.   End If
  182.   fTblStru.cIndexes = s
  183.   'reset the field for another
  184.   cIndexName = ""
  185.   cIndexName.SetFocus
  186.   cFieldNames = ""
  187.   cUniqueFlag = 1
  188.   GoTo AddIndexEnd
  189. AddIndexErr:
  190.   ShowError
  191.   Resume AddIndexEnd
  192. AddIndexEnd:
  193.   ResetMouse Me
  194. End Sub
  195.