home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / PVb5.0 / VB / SAMPLES / VISDATA / ADDINDEX.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-01-11  |  7.0 KB  |  234 lines

  1. VERSION 5.00
  2. Begin VB.Form frmAddIndex 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "
  5.    ClientHeight    =   3495
  6.    ClientLeft      =   2100
  7.    ClientTop       =   4215
  8.    ClientWidth     =   5400
  9.    ForeColor       =   &H00000000&
  10.    HelpContextID   =   2016118
  11.    Icon            =   "Addindex.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    LockControls    =   -1  'True
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   3067.929
  17.    ScaleMode       =   0  'User
  18.    ScaleWidth      =   5311.688
  19.    ShowInTaskbar   =   0   'False
  20.    StartUpPosition =   1  'CenterOwner
  21.    Begin VB.CheckBox chkIgnoreNulls 
  22.       Caption         =   "
  23.       Height          =   255
  24.       Left            =   3120
  25.       MaskColor       =   &H00000000&
  26.       TabIndex        =   5
  27.       Top             =   1320
  28.       Width           =   2188
  29.    End
  30.    Begin VB.CheckBox chkPrimary 
  31.       Caption         =   "
  32.       Height          =   255
  33.       Left            =   3120
  34.       MaskColor       =   &H00000000&
  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          =   1350
  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         =   "
  69.       Height          =   252
  70.       Left            =   3120
  71.       MaskColor       =   &H00000000&
  72.       TabIndex        =   4
  73.       Top             =   840
  74.       Value           =   1  'Checked
  75.       Width           =   2188
  76.    End
  77.    Begin VB.CommandButton cmdOK 
  78.       Caption         =   "
  79. (&O)"
  80.       Default         =   -1  'True
  81.       Enabled         =   0   'False
  82.       Height          =   375
  83.       Left            =   3240
  84.       MaskColor       =   &H00000000&
  85.       TabIndex        =   6
  86.       Top             =   2400
  87.       Width           =   1815
  88.    End
  89.    Begin VB.CommandButton cmdClose 
  90.       Cancel          =   -1  'True
  91.       Caption         =   "
  92. (&C)"
  93.       Height          =   375
  94.       Left            =   3240
  95.       MaskColor       =   &H00000000&
  96.       TabIndex        =   7
  97.       Top             =   2880
  98.       Width           =   1815
  99.    End
  100.    Begin VB.Label lblLabels 
  101.       AutoSize        =   -1  'True
  102.       Caption         =   "
  103.       Height          =   195
  104.       Index           =   2
  105.       Left            =   120
  106.       TabIndex        =   10
  107.       Top             =   1560
  108.       Width           =   1200
  109.    End
  110.    Begin VB.Label lblLabels 
  111.       AutoSize        =   -1  'True
  112.       Caption         =   "
  113.       Height          =   195
  114.       Index           =   1
  115.       Left            =   120
  116.       TabIndex        =   9
  117.       Top             =   720
  118.       Width           =   1155
  119.    End
  120.    Begin VB.Label lblLabels 
  121.       AutoSize        =   -1  'True
  122.       Caption         =   "
  123.       Height          =   195
  124.       Index           =   0
  125.       Left            =   120
  126.       TabIndex        =   8
  127.       Top             =   120
  128.       Width           =   510
  129.    End
  130. Attribute VB_Name = "frmAddIndex"
  131. Attribute VB_GlobalNameSpace = False
  132. Attribute VB_Creatable = False
  133. Attribute VB_PredeclaredId = True
  134. Attribute VB_Exposed = False
  135. Option Explicit
  136. '>>>>>>>>>>>>>>>>>>>>>>>>
  137. Const FORMCAPTION = "
  138. Const BUTTON1 = "
  139. (&O)"
  140. Const BUTTON2 = "
  141. (&C)"
  142. Const LABEL0 = "
  143. Const Label1 = "
  144. Const Label2 = "
  145. '>>>>>>>>>>>>>>>>>>>>>>>>
  146. Private Sub lstFields_Click()
  147.   Dim sTmp As String
  148.   sTmp = txtFields.Text
  149.   If Len(sTmp) = 0 Then
  150.     txtFields.Text = sTmp & lstFields
  151.   Else
  152.     txtFields.Text = sTmp & ";" & lstFields
  153.   End If
  154.   txtFields.Refresh
  155. End Sub
  156. Private Sub txtFields_Change()
  157.   cmdOK.Enabled = Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0
  158. End Sub
  159. Private Sub txtFields_LostFocus()
  160.   cmdOK.Enabled = Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0
  161. End Sub
  162. Private Sub txtIndexName_LostFocus()
  163.   cmdOK.Enabled = Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0
  164. End Sub
  165. Private Sub cmdClose_Click()
  166.   Unload Me
  167. End Sub
  168. Private Sub Form_Load()
  169.   Dim tblTableDef As TableDef
  170.   Dim fld As Field
  171.   Dim i As Integer
  172.   Me.Caption = FORMCAPTION
  173.   cmdOK.Caption = BUTTON1
  174.   cmdClose.Caption = BUTTON2
  175.   lblLabels(0).Caption = LABEL0
  176.   lblLabels(1).Caption = Label1
  177.   lblLabels(2).Caption = Label2
  178.   If gbAddTableFlag Then
  179.     Me.Caption = Me.Caption & " to " & frmTblStruct.txtTableName
  180.     For i = 0 To frmTblStruct.lstFields.ListCount - 1
  181.       lstFields.AddItem frmTblStruct.lstFields.List(i)
  182.     Next
  183.   Else
  184.     Me.Caption = Me.Caption & "
  185. " & StripConnect(gnodDBNode2.Text)
  186.     Set tblTableDef = gdbCurrentDB.TableDefs(StripConnect(gnodDBNode2.Text))
  187.     ListItemNames tblTableDef.Fields, lstFields, False
  188.   End If
  189.   If gsDataType <> gsMSACCESS Then
  190.     chkPrimary.Enabled = False
  191.     chkIgnoreNulls.Enabled = False
  192.     chkPrimary.Value = vbGrayed
  193.     chkIgnoreNulls.Value = vbGrayed
  194.   End If
  195.   SetDefaults
  196. End Sub
  197. Private Sub txtIndexName_Change()
  198.   cmdOK.Enabled = Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0
  199. End Sub
  200. Private Sub cmdOK_Click()
  201.   Dim indIndexObj As Index
  202.   Dim tblTableDefObj As TableDef
  203.   Dim sTmp As String
  204.   On Error GoTo AddIndexErr
  205.   Screen.MousePointer = vbHourglass
  206.   Set indIndexObj = gtdfTableDef.CreateIndex(txtIndexName.Text)
  207.   With indIndexObj
  208.     .Fields = txtFields.Text
  209.     .Unique = chkUnique.Value
  210.     If gsDataType = gsMSACCESS Then
  211.       .Primary = IIf(chkPrimary.Value, True, False)
  212.       .IgnoreNulls = IIf(chkIgnoreNulls.Value = vbChecked, True, False)
  213.     End If
  214.   End With
  215.  tblstruct 
  216.  tabledef 
  217.   gtdfTableDef.Indexes.Append indIndexObj
  218.   frmTblStruct.lstIndexes.AddItem txtIndexName.Text
  219.   frmTblStruct.lstIndexes.ListIndex = frmTblStruct.lstIndexes.NewIndex
  220.   SetDefaults
  221.   txtIndexName.SetFocus
  222.   Screen.MousePointer = vbDefault
  223.   Exit Sub
  224. AddIndexErr:
  225.   ShowError
  226. End Sub
  227. Private Sub SetDefaults()
  228.   txtIndexName.Text = vbNullString
  229.   If gsDataType = gsMSACCESS Then
  230.     txtFields.Text = vbNullString
  231.     chkUnique.Value = vbChecked
  232.   End If
  233. End Sub
  234.