home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form fAddField
- BorderStyle = 3 'Fixed Double
- Caption = "Add Field"
- Height = 2460
- Left = 5280
- LinkTopic = "Form1"
- ScaleHeight = 2040
- ScaleMode = 0 'User
- ScaleWidth = 3480
- Top = 4350
- Width = 3570
- Begin TextBox cFieldName
- Height = 290
- Left = 833
- TabIndex = 1
- Top = 121
- Width = 2510
- End
- Begin ComboBox cFieldType
- Height = 290
- Left = 833
- Style = 2 'Dropdown List
- TabIndex = 4
- Top = 604
- Width = 2510
- End
- Begin TextBox cFieldLength
- Enabled = 0 'False
- Height = 290
- Left = 833
- TabIndex = 5
- Top = 1088
- Width = 726
- End
- Begin CommandButton OkayButton
- Caption = "&OK"
- Default = -1 'True
- Enabled = 0 'False
- Height = 375
- Left = 357
- TabIndex = 6
- Top = 1571
- Width = 1083
- End
- Begin CommandButton CancelButton
- Cancel = -1 'True
- Caption = "&Close"
- Height = 375
- Left = 1903
- TabIndex = 7
- Top = 1571
- Width = 1083
- End
- Begin Label FieldSizeLabel
- Caption = "Size:"
- Height = 254
- Left = 119
- TabIndex = 3
- Top = 1088
- Width = 607
- End
- Begin Label FieldTypeLabel
- Caption = "Type:"
- Height = 254
- Left = 119
- TabIndex = 2
- Top = 604
- Width = 607
- End
- Begin Label FieldNameLabel
- Caption = "Name:"
- Height = 254
- Left = 119
- TabIndex = 0
- Top = 121
- Width = 607
- End
- Option Explicit
- Sub CancelButton_Click ()
- Unload Me
- End Sub
- Sub cFieldLength_Change ()
- 'activate the ok button only if all of the
- 'fields have something in it
- If cFieldName <> "" And cFieldType <> "" And Val(cFieldLength) > 0 Then
- OkayButton.Enabled = True
- Else
- OkayButton.Enabled = False
- End If
- End Sub
- Sub cFieldName_Change ()
- 'activate the ok button only if all of the
- 'fields have something in it
- If cFieldName <> "" And cFieldType <> "" And Val(cFieldLength) > 0 Then
- OkayButton.Enabled = True
- Else
- OkayButton.Enabled = False
- End If
- End Sub
- Sub cFieldType_Click ()
- 'call function to set size and type of field
- cFieldLength = SetFldProperties(CStr(cFieldType))
- cFieldLength.Enabled = False
- 'enable field length control for string and memo type
- If gwFldType = FT_STRING Then
- 'allow entry of field length
- cFieldLength.Enabled = True
- cFieldLength = "0"
- End If
- 'make sure that there is data in
- 'all fields before enabling the ok button
- If cFieldName <> "" Then
- OkayButton.Enabled = True
- Else
- OkayButton.Enabled = False
- End If
- End Sub
- Sub Form_Load ()
- 'populate the Field Type list on the form
- cFieldType.AddItem "True/False"
- cFieldType.AddItem "Byte"
- cFieldType.AddItem "Integer"
- cFieldType.AddItem "Long"
- cFieldType.AddItem "Currency"
- cFieldType.AddItem "Single"
- cFieldType.AddItem "Double"
- cFieldType.AddItem "Date/Time"
- cFieldType.AddItem "String"
- cFieldType.AddItem "Memo"
- End Sub
- Sub OkayButton_Click ()
- On Error GoTo OkayErr
- Dim f As New Field 'local field structure
- Dim tbln As String 'table name
- 'fill the field structure
- f.Name = cFieldName
- 'get field length from form for string and memo
- If gwFldType = FT_STRING Then
- gwFldSize = Val(cFieldLength)
- End If
- f.Type = gwFldType
- f.Size = gwFldSize
- tbln = fTables.cTableList
- If gfAddTableFlag = False Then
- gCurrentDB.TableDefs(tbln).Fields.Append f
- End If
- fTblStru.cFields.Row = 1
- fTblStru.cFields.Col = 0
- If fTblStru.cFields <> "" Then
- 'add a row if the first one isn't blank
- fTblStru.cFields.Rows = fTblStru.cFields.Rows + 1
- End If
- fTblStru.cFields.Row = fTblStru.cFields.Rows - 1
- fTblStru.cFields.Col = 0
- fTblStru.cFields = cFieldName
- fTblStru.cFields.Col = 1
- fTblStru.cFields = cFieldType
- fTblStru.cFields.Col = 2
- fTblStru.cFields = cFieldLength
- If fTblStru.cFields.Rows < 12 Then
- fTblStru.cFields.Height = fTblStru.cFields.Rows * 232
- fTblStru.FieldBox.Height = fTblStru.cFields.Height + 360
- fTblStru.IndexBox.Top = fTblStru.FieldBox.Top + fTblStru.FieldBox.Height + 250
- fTblStru.Height = fTblStru.IndexBox.Top + fTblStru.IndexBox.Height + 500
- End If
- 'clear the name and allow entry of another
- cFieldName = ""
- cFieldName.SetFocus
- GoTo OkayEnd
- OkayErr:
- ShowError
- Resume OkayEnd
- OkayEnd:
- End Sub
-