home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form fIndexAdd
- BorderStyle = 3 'Fixed Double
- Caption = "Add Index"
- Height = 3180
- Left = 3795
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 2760
- ScaleMode = 0 'User
- ScaleWidth = 4932
- Top = 3450
- Width = 5025
- Begin TextBox cIndexName
- Height = 290
- Left = 955
- TabIndex = 0
- Top = 121
- Width = 2518
- End
- Begin TextBox cFieldNames
- Height = 531
- Left = 955
- MultiLine = -1 'True
- TabIndex = 1
- Top = 483
- Width = 2518
- End
- Begin ListBox cFieldList
- Columns = 2
- Height = 1590
- Left = 960
- Sorted = -1 'True
- TabIndex = 7
- Top = 1080
- Width = 2520
- End
- Begin CheckBox cUniqueFlag
- Caption = "Unique"
- Height = 253
- Left = 3580
- TabIndex = 8
- Top = 603
- Value = 1 'Checked
- Width = 1086
- End
- Begin CommandButton OkayButton
- Caption = "&OK"
- Default = -1 'True
- Enabled = 0 'False
- Height = 374
- Left = 3580
- TabIndex = 4
- Top = 1327
- Width = 1205
- End
- Begin CommandButton CloseButton
- Cancel = -1 'True
- Caption = "&Close"
- Height = 374
- Left = 3580
- TabIndex = 5
- Top = 1930
- Width = 1205
- End
- Begin Label FieldListLabel
- Caption = "Fields:"
- Height = 253
- Left = 119
- TabIndex = 6
- Top = 1086
- Width = 847
- End
- Begin Label FieldsLabel
- Caption = "Indexed Fields:"
- Height = 495
- Left = 119
- TabIndex = 3
- Top = 483
- Width = 847
- End
- Begin Label NameLabel
- Caption = "Name:"
- Height = 253
- Left = 119
- TabIndex = 2
- Top = 121
- Width = 847
- End
- Option Explicit
- Sub cFieldList_Click ()
- Dim s As String
- s = cFieldNames
- If s = "" Then
- cFieldNames = s + cFieldList
- Else
- cFieldNames = s + ";" + cFieldList
- End If
- cFieldNames.Refresh
- End Sub
- Sub cFieldNames_Change ()
- If cIndexName <> "" And cFieldNames <> "" Then
- OkayButton.Enabled = True
- Else
- OkayButton.Enabled = False
- End If
- End Sub
- Sub cFieldNames_LostFocus ()
- If cIndexName <> "" And cFieldNames <> "" Then
- OkayButton.Enabled = True
- Else
- OkayButton.Enabled = False
- End If
- End Sub
- Sub cIndexName_LostFocus ()
- If cIndexName <> "" And cFieldNames <> "" Then
- OkayButton.Enabled = True
- Else
- OkayButton.Enabled = False
- End If
- End Sub
- Sub CloseButton_Click ()
- Unload Me
- End Sub
- Sub Form_Load ()
- Dim t As TableDef
- Dim i As Integer
- If gfAddTableFlag = True Then
- Caption = Caption + " to " + fTblStru.cTableName
- fTblStru.cFields.Col = 0
- For i = 1 To fTblStru.cFields.Rows - 1
- fTblStru.cFields.Row = i
- cFieldList.AddItem fTblStru.cFields
- Next
- Else
- Caption = Caption + " to " + fTables.cTableList
- Set t = gCurrentDB.TableDefs(fTables.cTableList)
- t.Fields.Refresh
- For i = 0 To t.Fields.Count - 1
- cFieldList.AddItem t.Fields(i).Name
- Next
- End If
- End Sub
- Sub IndexName_Change ()
- If cIndexName <> "" And cFieldNames <> "" Then
- OkayButton.Enabled = True
- Else
- OkayButton.Enabled = False
- End If
- End Sub
- Sub OkayButton_Click ()
- Dim i As New Index
- Dim t As TableDef
- Dim s As String
- On Error GoTo AddIndexErr
- SetHourGlass Me
- i.Name = cIndexName
- i.Fields = cFieldNames
- i.Unique = cUniqueFlag
- If gfAddTableFlag = False Then
- Set t = gCurrentDB.TableDefs(fTables.cTableList)
- t.Indexes.Append i
- End If
- fTblStru.cIndexes.Row = 1
- fTblStru.cIndexes.Col = 0
- If fTblStru.cIndexes <> "" Then
- 'add a row if the first one isn't blank
- fTblStru.cIndexes.Rows = fTblStru.cIndexes.Rows + 1
- End If
- fTblStru.cIndexes.Row = fTblStru.cIndexes.Rows - 1
- fTblStru.cIndexes.Col = 0
- fTblStru.cIndexes = cIndexName
- fTblStru.cIndexes.Col = 1
- fTblStru.cIndexes = cFieldNames
- fTblStru.cIndexes.Col = 2
- If i.Unique = False Then
- s = s + "False"
- Else
- s = s + "True"
- End If
- fTblStru.cIndexes = s
- 'reset the field for another
- cIndexName = ""
- cIndexName.SetFocus
- cFieldNames = ""
- cUniqueFlag = 1
- GoTo AddIndexEnd
- AddIndexErr:
- ShowError
- Resume AddIndexEnd
- AddIndexEnd:
- ResetMouse Me
- End Sub
-