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

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