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

  1. VERSION 2.00
  2. Begin Form fAddField 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Add Field"
  5.    Height          =   2460
  6.    Left            =   5280
  7.    LinkTopic       =   "Form1"
  8.    ScaleHeight     =   2040
  9.    ScaleMode       =   0  'User
  10.    ScaleWidth      =   3480
  11.    Top             =   4350
  12.    Width           =   3570
  13.    Begin TextBox cFieldName 
  14.       Height          =   290
  15.       Left            =   833
  16.       TabIndex        =   1
  17.       Top             =   121
  18.       Width           =   2510
  19.    End
  20.    Begin ComboBox cFieldType 
  21.       Height          =   290
  22.       Left            =   833
  23.       Style           =   2  'Dropdown List
  24.       TabIndex        =   4
  25.       Top             =   604
  26.       Width           =   2510
  27.    End
  28.    Begin TextBox cFieldLength 
  29.       Enabled         =   0   'False
  30.       Height          =   290
  31.       Left            =   833
  32.       TabIndex        =   5
  33.       Top             =   1088
  34.       Width           =   726
  35.    End
  36.    Begin CommandButton OkayButton 
  37.       Caption         =   "&OK"
  38.       Default         =   -1  'True
  39.       Enabled         =   0   'False
  40.       Height          =   375
  41.       Left            =   357
  42.       TabIndex        =   6
  43.       Top             =   1571
  44.       Width           =   1083
  45.    End
  46.    Begin CommandButton CancelButton 
  47.       Cancel          =   -1  'True
  48.       Caption         =   "&Close"
  49.       Height          =   375
  50.       Left            =   1903
  51.       TabIndex        =   7
  52.       Top             =   1571
  53.       Width           =   1083
  54.    End
  55.    Begin Label FieldSizeLabel 
  56.       Caption         =   "Size:"
  57.       Height          =   254
  58.       Left            =   119
  59.       TabIndex        =   3
  60.       Top             =   1088
  61.       Width           =   607
  62.    End
  63.    Begin Label FieldTypeLabel 
  64.       Caption         =   "Type:"
  65.       Height          =   254
  66.       Left            =   119
  67.       TabIndex        =   2
  68.       Top             =   604
  69.       Width           =   607
  70.    End
  71.    Begin Label FieldNameLabel 
  72.       Caption         =   "Name:"
  73.       Height          =   254
  74.       Left            =   119
  75.       TabIndex        =   0
  76.       Top             =   121
  77.       Width           =   607
  78.    End
  79. Option Explicit
  80. Sub CancelButton_Click ()
  81.   Unload Me
  82. End Sub
  83. Sub cFieldLength_Change ()
  84.   'activate the ok button only if all of the
  85.   'fields have something in it
  86.   If cFieldName <> "" And cFieldType <> "" And Val(cFieldLength) > 0 Then
  87.     OkayButton.Enabled = True
  88.   Else
  89.     OkayButton.Enabled = False
  90.   End If
  91. End Sub
  92. Sub cFieldName_Change ()
  93.   'activate the ok button only if all of the
  94.   'fields have something in it
  95.   If cFieldName <> "" And cFieldType <> "" And Val(cFieldLength) > 0 Then
  96.     OkayButton.Enabled = True
  97.   Else
  98.     OkayButton.Enabled = False
  99.   End If
  100. End Sub
  101. Sub cFieldType_Click ()
  102.   'call function to set size and type of field
  103.   cFieldLength = SetFldProperties(CStr(cFieldType))
  104.   cFieldLength.Enabled = False
  105.   'enable field length control for string and memo type
  106.   If gwFldType = FT_STRING Then
  107.     'allow entry of field length
  108.     cFieldLength.Enabled = True
  109.     cFieldLength = "0"
  110.   End If
  111.   'make sure that there is data in
  112.   'all fields before enabling the ok button
  113.   If cFieldName <> "" Then
  114.     OkayButton.Enabled = True
  115.   Else
  116.     OkayButton.Enabled = False
  117.   End If
  118. End Sub
  119. Sub Form_Load ()
  120.   'populate the Field Type list on the form
  121.   cFieldType.AddItem "True/False"
  122.   cFieldType.AddItem "Byte"
  123.   cFieldType.AddItem "Integer"
  124.   cFieldType.AddItem "Long"
  125.   cFieldType.AddItem "Currency"
  126.   cFieldType.AddItem "Single"
  127.   cFieldType.AddItem "Double"
  128.   cFieldType.AddItem "Date/Time"
  129.   cFieldType.AddItem "String"
  130.   cFieldType.AddItem "Memo"
  131. End Sub
  132. Sub OkayButton_Click ()
  133.   On Error GoTo OkayErr
  134.   Dim f As New Field     'local field structure
  135.   Dim tbln As String     'table name
  136.   'fill the field structure
  137.   f.Name = cFieldName
  138.   'get field length from form for string and memo
  139.   If gwFldType = FT_STRING Then
  140.     gwFldSize = Val(cFieldLength)
  141.   End If
  142.   f.Type = gwFldType
  143.   f.Size = gwFldSize
  144.   tbln = fTables.cTableList
  145.   If gfAddTableFlag = False Then
  146.     gCurrentDB.TableDefs(tbln).Fields.Append f
  147.   End If
  148.   fTblStru.cFields.Row = 1
  149.   fTblStru.cFields.Col = 0
  150.   If fTblStru.cFields <> "" Then
  151.     'add a row if the first one isn't blank
  152.     fTblStru.cFields.Rows = fTblStru.cFields.Rows + 1
  153.   End If
  154.   fTblStru.cFields.Row = fTblStru.cFields.Rows - 1
  155.   fTblStru.cFields.Col = 0
  156.   fTblStru.cFields = cFieldName
  157.   fTblStru.cFields.Col = 1
  158.   fTblStru.cFields = cFieldType
  159.   fTblStru.cFields.Col = 2
  160.   fTblStru.cFields = cFieldLength
  161.   If fTblStru.cFields.Rows < 12 Then
  162.     fTblStru.cFields.Height = fTblStru.cFields.Rows * 232
  163.     fTblStru.FieldBox.Height = fTblStru.cFields.Height + 360
  164.     fTblStru.IndexBox.Top = fTblStru.FieldBox.Top + fTblStru.FieldBox.Height + 250
  165.     fTblStru.Height = fTblStru.IndexBox.Top + fTblStru.IndexBox.Height + 500
  166.   End If
  167.   'clear the name and allow entry of another
  168.   cFieldName = ""
  169.   cFieldName.SetFocus
  170.   GoTo OkayEnd
  171. OkayErr:
  172.   ShowError
  173.   Resume OkayEnd
  174. OkayEnd:
  175. End Sub
  176.