home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l405 / 4.ddi / INDEXADD.FR_ / INDEXADD.bin (.txt)
Encoding:
Visual Basic Form  |  1993-04-28  |  6.4 KB  |  238 lines

  1. VERSION 2.00
  2. Begin Form fIndexAdd 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Add Index"
  6.    ClientHeight    =   2775
  7.    ClientLeft      =   3855
  8.    ClientTop       =   3795
  9.    ClientWidth     =   4905
  10.    ControlBox      =   0   'False
  11.    ForeColor       =   &H00C0C0C0&
  12.    Height          =   3180
  13.    Left            =   3795
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   2760
  18.    ScaleMode       =   0  'User
  19.    ScaleWidth      =   4932
  20.    Top             =   3450
  21.    Width           =   5025
  22.    Begin CheckBox cPrimaryFlag 
  23.       BackColor       =   &H00C0C0C0&
  24.       Caption         =   "Primary"
  25.       Height          =   252
  26.       Left            =   3570
  27.       TabIndex        =   9
  28.       Top             =   105
  29.       Value           =   1  'Checked
  30.       Width           =   1092
  31.    End
  32.    Begin TextBox cIndexName 
  33.       BackColor       =   &H00FFFFFF&
  34.       Height          =   288
  35.       Left            =   960
  36.       TabIndex        =   0
  37.       Tag             =   "OL"
  38.       Top             =   120
  39.       Width           =   2532
  40.    End
  41.    Begin TextBox cFieldNames 
  42.       BackColor       =   &H00FFFFFF&
  43.       Height          =   528
  44.       Left            =   960
  45.       MultiLine       =   -1  'True
  46.       TabIndex        =   1
  47.       Tag             =   "OL"
  48.       Top             =   480
  49.       Width           =   2532
  50.    End
  51.    Begin ListBox cFieldList 
  52.       BackColor       =   &H00FFFFFF&
  53.       Columns         =   2
  54.       Height          =   1590
  55.       Left            =   960
  56.       Sorted          =   -1  'True
  57.       TabIndex        =   7
  58.       Tag             =   "OL"
  59.       Top             =   1080
  60.       Width           =   2535
  61.    End
  62.    Begin CheckBox cUniqueFlag 
  63.       BackColor       =   &H00C0C0C0&
  64.       Caption         =   "Unique"
  65.       Height          =   252
  66.       Left            =   3570
  67.       TabIndex        =   8
  68.       Top             =   525
  69.       Value           =   1  'Checked
  70.       Width           =   1092
  71.    End
  72.    Begin CommandButton OkayButton 
  73.       BackColor       =   &H00C0C0C0&
  74.       Caption         =   "&OK"
  75.       Default         =   -1  'True
  76.       Enabled         =   0   'False
  77.       Height          =   372
  78.       Left            =   3600
  79.       TabIndex        =   4
  80.       Top             =   1320
  81.       Width           =   1212
  82.    End
  83.    Begin CommandButton CloseButton 
  84.       BackColor       =   &H00C0C0C0&
  85.       Cancel          =   -1  'True
  86.       Caption         =   "&Close"
  87.       Height          =   372
  88.       Left            =   3600
  89.       TabIndex        =   5
  90.       Top             =   1920
  91.       Width           =   1212
  92.    End
  93.    Begin Label FieldListLabel 
  94.       BackColor       =   &H00C0C0C0&
  95.       Caption         =   "Fields:"
  96.       Height          =   252
  97.       Left            =   120
  98.       TabIndex        =   6
  99.       Top             =   1080
  100.       Width           =   732
  101.    End
  102.    Begin Label FieldsLabel 
  103.       BackColor       =   &H00C0C0C0&
  104.       Caption         =   "Indexed Fields:"
  105.       Height          =   492
  106.       Left            =   120
  107.       TabIndex        =   3
  108.       Top             =   480
  109.       Width           =   732
  110.    End
  111.    Begin Label NameLabel 
  112.       BackColor       =   &H00C0C0C0&
  113.       Caption         =   "Name:"
  114.       Height          =   252
  115.       Left            =   120
  116.       TabIndex        =   2
  117.       Top             =   120
  118.       Width           =   732
  119.    End
  120. Option Explicit
  121. Sub cFieldList_Click ()
  122.   Dim s As String
  123.   s = cFieldNames
  124.   If s = "" Then
  125.     cFieldNames = s + cFieldList
  126.   Else
  127.     cFieldNames = s + ";" + cFieldList
  128.   End If
  129.   cFieldNames.Refresh
  130. End Sub
  131. Sub cFieldNames_Change ()
  132.   If cIndexName <> "" And cFieldNames <> "" Then
  133.     OkayButton.Enabled = True
  134.   Else
  135.     OkayButton.Enabled = False
  136.   End If
  137. End Sub
  138. Sub cFieldNames_LostFocus ()
  139.   If cIndexName <> "" And cFieldNames <> "" Then
  140.     OkayButton.Enabled = True
  141.   Else
  142.     OkayButton.Enabled = False
  143.   End If
  144. End Sub
  145. Sub cIndexName_LostFocus ()
  146.   If cIndexName <> "" And cFieldNames <> "" Then
  147.     OkayButton.Enabled = True
  148.   Else
  149.     OkayButton.Enabled = False
  150.   End If
  151. End Sub
  152. Sub CloseButton_Click ()
  153.   Unload Me
  154. End Sub
  155. Sub Form_Load ()
  156.   Dim t As TableDef
  157.   Dim i As Integer
  158.   If gfAddTableFlag = True Then
  159.     Caption = Caption + " to " + fTblStru.cTableName
  160.     fTblStru.cFields.Col = 0
  161.     For i = 1 To fTblStru.cFields.Rows - 1
  162.       fTblStru.cFields.Row = i
  163.       cFieldList.AddItem fTblStru.cFields
  164.     Next
  165.   Else
  166.     Caption = Caption + " to " + fTables.cTableList
  167.     Set t = gCurrentDB.TableDefs(fTables.cTableList)
  168.     For i = 0 To t.Fields.Count - 1
  169.       cFieldList.AddItem t.Fields(i).Name
  170.     Next
  171.   End If
  172. End Sub
  173. Sub Form_Paint ()
  174.   Outlines Me
  175. End Sub
  176. Sub IndexName_Change ()
  177.   If cIndexName <> "" And cFieldNames <> "" Then
  178.     OkayButton.Enabled = True
  179.   Else
  180.     OkayButton.Enabled = False
  181.   End If
  182. End Sub
  183. Sub OkayButton_Click ()
  184.   Dim i As New Index
  185.   Dim t As TableDef
  186.   Dim s As String
  187.   On Error GoTo AddIndexErr
  188.   SetHourglass Me
  189.   i.Name = cIndexName
  190.   i.Fields = cFieldNames
  191.   i.Unique = cUniqueFlag
  192.   If gstDataType <> "ODBC" Then i.Primary = cPrimaryFlag
  193.   If gfAddTableFlag = False Then
  194.     Set t = gCurrentDB.TableDefs(fTables.cTableList)
  195.     t.Indexes.Append i
  196.   End If
  197.   fTblStru.cIndexes.Row = 1
  198.   fTblStru.cIndexes.Col = 0
  199.   If fTblStru.cIndexes <> "" Then
  200.     'add a row if the first one isn't blank
  201.     fTblStru.cIndexes.Rows = fTblStru.cIndexes.Rows + 1
  202.   End If
  203.   fTblStru.cIndexes.Row = fTblStru.cIndexes.Rows - 1
  204.   fTblStru.cIndexes.Col = 0
  205.   fTblStru.cIndexes = cIndexName
  206.   fTblStru.cIndexes.Col = 1
  207.   fTblStru.cIndexes = cFieldNames
  208.   fTblStru.cIndexes.Col = 2
  209.   If i.Unique = False Then
  210.     s = "False"
  211.   Else
  212.     s = "True"
  213.   End If
  214.   fTblStru.cIndexes = s
  215.   fTblStru.cIndexes.Col = 3
  216.   If gstDataType = "ODBC" Then
  217.     s = "N/A"
  218.   Else
  219.     If i.Primary = False Then
  220.       s = "False"
  221.     Else
  222.       s = "True"
  223.     End If
  224.   End If
  225.   fTblStru.cIndexes = s
  226.   'reset the field for another
  227.   cIndexName = ""
  228.   cIndexName.SetFocus
  229.   cFieldNames = ""
  230.   cUniqueFlag = 1
  231.   GoTo AddIndexEnd
  232. AddIndexErr:
  233.   ShowError
  234.   Resume AddIndexEnd
  235. AddIndexEnd:
  236.   ResetMouse Me
  237. End Sub
  238.