home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l407 / 5.ddi / TABLEOBJ.FR_ / TABLEOBJ.bin (.txt)
Encoding:
Visual Basic Form  |  1993-04-28  |  25.5 KB  |  864 lines

  1. VERSION 2.00
  2. Begin Form fTableObj 
  3.    BackColor       =   &H00C0C0C0&
  4.    ClientHeight    =   3495
  5.    ClientLeft      =   1335
  6.    ClientTop       =   2625
  7.    ClientWidth     =   5655
  8.    Height          =   3900
  9.    Icon            =   TABLEOBJ.FRX:0000
  10.    KeyPreview      =   -1  'True
  11.    Left            =   1275
  12.    LinkTopic       =   "Form1"
  13.    MDIChild        =   -1  'True
  14.    ScaleHeight     =   3480
  15.    ScaleMode       =   0  'User
  16.    ScaleWidth      =   5675.317
  17.    Tag             =   "Dynaset"
  18.    Top             =   2280
  19.    Width           =   5775
  20.    Begin PictureBox FieldHeader 
  21.       BackColor       =   &H00C0C0C0&
  22.       BorderStyle     =   0  'None
  23.       Height          =   240
  24.       Left            =   0
  25.       ScaleHeight     =   240
  26.       ScaleMode       =   0  'User
  27.       ScaleWidth      =   5028
  28.       TabIndex        =   22
  29.       Top             =   720
  30.       Width           =   5025
  31.       Begin Label FieldValueLabel 
  32.          BackColor       =   &H00C0C0C0&
  33.          Caption         =   " Value  (F4=Zoom) "
  34.          Height          =   255
  35.          Left            =   1680
  36.          TabIndex        =   24
  37.          Top             =   0
  38.          Width           =   3165
  39.       End
  40.       Begin Label FieldHdrLabel 
  41.          BackColor       =   &H00C0C0C0&
  42.          Caption         =   "Field Name:"
  43.          Height          =   252
  44.          Left            =   120
  45.          TabIndex        =   23
  46.          Top             =   0
  47.          Width           =   1212
  48.       End
  49.    End
  50.    Begin PictureBox ViewButtons 
  51.       Align           =   1  'Align Top
  52.       BackColor       =   &H00C0C0C0&
  53.       BorderStyle     =   0  'None
  54.       Height          =   735
  55.       Left            =   0
  56.       ScaleHeight     =   735
  57.       ScaleMode       =   0  'User
  58.       ScaleWidth      =   5658.376
  59.       TabIndex        =   1
  60.       TabStop         =   0   'False
  61.       Top             =   0
  62.       Width           =   5655
  63.       Begin ComboBox cIndexes 
  64.          BackColor       =   &H00FFFFFF&
  65.          Height          =   300
  66.          Left            =   720
  67.          Style           =   2  'Dropdown List
  68.          TabIndex        =   9
  69.          Tag             =   "OL"
  70.          Top             =   360
  71.          Width           =   4335
  72.       End
  73.       Begin CommandButton SeekButton 
  74.          Caption         =   "&Seek"
  75.          Height          =   330
  76.          Left            =   2160
  77.          TabIndex        =   5
  78.          Top             =   0
  79.          Width           =   750
  80.       End
  81.       Begin CommandButton FilterButton 
  82.          Caption         =   "F&ilter"
  83.          Height          =   330
  84.          Left            =   2880
  85.          TabIndex        =   6
  86.          Top             =   0
  87.          Width           =   750
  88.       End
  89.       Begin CommandButton CloseButton 
  90.          Cancel          =   -1  'True
  91.          Caption         =   "&Close"
  92.          Height          =   330
  93.          Left            =   4305
  94.          TabIndex        =   8
  95.          TabStop         =   0   'False
  96.          Top             =   0
  97.          Width           =   750
  98.       End
  99.       Begin CommandButton PropButton 
  100.          Caption         =   "&Prop"
  101.          Height          =   330
  102.          Left            =   3600
  103.          TabIndex        =   7
  104.          Top             =   0
  105.          Width           =   750
  106.       End
  107.       Begin CommandButton DelButton 
  108.          Caption         =   "&Del"
  109.          Height          =   330
  110.          Left            =   1440
  111.          TabIndex        =   4
  112.          Top             =   0
  113.          Width           =   750
  114.       End
  115.       Begin CommandButton EditButton 
  116.          Caption         =   "&Edit"
  117.          Height          =   330
  118.          Left            =   720
  119.          TabIndex        =   3
  120.          Top             =   0
  121.          Width           =   750
  122.       End
  123.       Begin CommandButton AddButton 
  124.          Caption         =   "&Add"
  125.          Height          =   330
  126.          Left            =   0
  127.          TabIndex        =   2
  128.          Top             =   0
  129.          Width           =   750
  130.       End
  131.       Begin Label IndexLabel 
  132.          BackColor       =   &H00C0C0C0&
  133.          Caption         =   "Index:"
  134.          Height          =   255
  135.          Left            =   120
  136.          TabIndex        =   25
  137.          Top             =   400
  138.          Width           =   615
  139.       End
  140.    End
  141.    Begin PictureBox ChangeButtons 
  142.       BackColor       =   &H00C0C0C0&
  143.       BorderStyle     =   0  'None
  144.       Height          =   690
  145.       Left            =   0
  146.       ScaleHeight     =   690
  147.       ScaleMode       =   0  'User
  148.       ScaleWidth      =   5658.376
  149.       TabIndex        =   14
  150.       TabStop         =   0   'False
  151.       Top             =   0
  152.       Visible         =   0   'False
  153.       Width           =   5655
  154.       Begin CommandButton UpdateButton 
  155.          Caption         =   "&Update"
  156.          Height          =   372
  157.          Left            =   960
  158.          TabIndex        =   16
  159.          Top             =   48
  160.          Width           =   1212
  161.       End
  162.       Begin CommandButton CancelButton 
  163.          Caption         =   "&Cancel"
  164.          Height          =   372
  165.          Left            =   2640
  166.          TabIndex        =   15
  167.          Top             =   48
  168.          Width           =   1212
  169.       End
  170.    End
  171.    Begin PictureBox StatBox 
  172.       Align           =   2  'Align Bottom
  173.       BackColor       =   &H00C0C0C0&
  174.       BorderStyle     =   0  'None
  175.       Height          =   281
  176.       Left            =   0
  177.       ScaleHeight     =   298.153
  178.       ScaleMode       =   0  'User
  179.       ScaleWidth      =   5665.189
  180.       TabIndex        =   20
  181.       TabStop         =   0   'False
  182.       Top             =   3210
  183.       Width           =   5655
  184.       Begin CommandButton NextButton 
  185.          Caption         =   ">"
  186.          FontBold        =   -1  'True
  187.          FontItalic      =   0   'False
  188.          FontName        =   "MS Sans Serif"
  189.          FontSize        =   12
  190.          FontStrikethru  =   0   'False
  191.          FontUnderline   =   0   'False
  192.          Height          =   287
  193.          Left            =   4200
  194.          TabIndex        =   12
  195.          Top             =   0
  196.          Width           =   375
  197.       End
  198.       Begin CommandButton LastButton 
  199.          Caption         =   ">|"
  200.          FontBold        =   -1  'True
  201.          FontItalic      =   0   'False
  202.          FontName        =   "MS Sans Serif"
  203.          FontSize        =   12
  204.          FontStrikethru  =   0   'False
  205.          FontUnderline   =   0   'False
  206.          Height          =   287
  207.          Left            =   4575
  208.          TabIndex        =   13
  209.          Top             =   0
  210.          Width           =   375
  211.       End
  212.       Begin CommandButton FirstButton 
  213.          Caption         =   "|<"
  214.          FontBold        =   -1  'True
  215.          FontItalic      =   0   'False
  216.          FontName        =   "MS Sans Serif"
  217.          FontSize        =   12
  218.          FontStrikethru  =   0   'False
  219.          FontUnderline   =   0   'False
  220.          Height          =   287
  221.          Left            =   0
  222.          TabIndex        =   10
  223.          Top             =   0
  224.          Width           =   375
  225.       End
  226.       Begin CommandButton PrevButton 
  227.          Caption         =   "<"
  228.          FontBold        =   -1  'True
  229.          FontItalic      =   0   'False
  230.          FontName        =   "MS Sans Serif"
  231.          FontSize        =   12
  232.          FontStrikethru  =   0   'False
  233.          FontUnderline   =   0   'False
  234.          Height          =   287
  235.          Left            =   375
  236.          TabIndex        =   11
  237.          Top             =   0
  238.          Width           =   375
  239.       End
  240.       Begin Label cStatusBar 
  241.          BackColor       =   &H00FFFFFF&
  242.          BorderStyle     =   1  'Fixed Single
  243.          Height          =   285
  244.          Left            =   735
  245.          TabIndex        =   21
  246.          Top             =   0
  247.          Width           =   3360
  248.       End
  249.    End
  250.    Begin VScrollBar cScrollBar 
  251.       Height          =   2616
  252.       LargeChange     =   3000
  253.       Left            =   5040
  254.       SmallChange     =   300
  255.       TabIndex        =   19
  256.       Top             =   960
  257.       Visible         =   0   'False
  258.       Width           =   252
  259.    End
  260.    Begin PictureBox cFields 
  261.       BackColor       =   &H00C0C0C0&
  262.       BorderStyle     =   0  'None
  263.       Height          =   375
  264.       Left            =   120
  265.       ScaleHeight     =   372
  266.       ScaleMode       =   0  'User
  267.       ScaleWidth      =   4812
  268.       TabIndex        =   17
  269.       TabStop         =   0   'False
  270.       Top             =   960
  271.       Width           =   4815
  272.       Begin TextBox cFieldData 
  273.          BackColor       =   &H00FFFFFF&
  274.          DataSource      =   "Data1"
  275.          ForeColor       =   &H00000000&
  276.          Height          =   288
  277.          Index           =   0
  278.          Left            =   1560
  279.          TabIndex        =   0
  280.          Top             =   0
  281.          Visible         =   0   'False
  282.          Width           =   3252
  283.       End
  284.       Begin Label cFieldName 
  285.          BackColor       =   &H00C0C0C0&
  286.          ForeColor       =   &H00000000&
  287.          Height          =   252
  288.          Index           =   0
  289.          Left            =   0
  290.          TabIndex        =   18
  291.          Top             =   60
  292.          Visible         =   0   'False
  293.          Width           =   1572
  294.       End
  295.    End
  296. Option Explicit
  297. 'form variables
  298. Dim FTBL As Table             'current form's table
  299. Dim FTblName As String        'form dynaset table name
  300. Dim FBM As String             'form bookmark
  301. Dim FNotFound As Integer      'used by find function
  302. Dim FAtTop As Integer         'top flag
  303. Dim FEditFlag As Integer      'edit mode
  304. Dim FAddNewFlag As Integer    'add mode
  305. Dim FFldDataChanged As Integer
  306. Dim FSeekForm As New fSeek    'seek form instance
  307. Dim FCurrRec As Integer       'record counter
  308. Dim FNumbRows As Long         'total rows in Table
  309. Sub AddButton_Click ()
  310.   On Error GoTo AddErr
  311.   'set the mode
  312.   FTBL.AddNew
  313.   cStatusBar = "Add record"
  314.   FAddNewFlag = True
  315.   If FTBL.RecordCount > 0 Then
  316.     FBM = FTBL.Bookmark
  317.   Else
  318.     FBM = ""
  319.   End If
  320.   ChangeButtons.Visible = True
  321.   ViewButtons.Visible = False
  322.   NextButton.Enabled = False
  323.   FirstButton.Enabled = False
  324.   LastButton.Enabled = False
  325.   PrevButton.Enabled = False
  326.   ClearDataFields
  327.   cFieldData(0).SetFocus
  328.   GoTo AddEnd
  329. AddErr:
  330.   ShowError
  331.   Resume AddEnd
  332. AddEnd:
  333. End Sub
  334. Sub CancelButton_Click ()
  335.    On Error Resume Next
  336.    ChangeButtons.Visible = False
  337.    ViewButtons.Visible = True
  338.    NextButton.Enabled = True
  339.    FirstButton.Enabled = True
  340.    LastButton.Enabled = True
  341.    PrevButton.Enabled = True
  342.    FEditFlag = False
  343.    FAddNewFlag = False
  344.    If FBM <> "" Then FTBL.Bookmark = FBM
  345.    DisplayCurrentRecord
  346. End Sub
  347. Sub cFieldData_Change (Index As Integer)
  348.   'just set the flag if data is changed
  349.   'it gets reset to false when a new record is displayed
  350.   FFldDataChanged = True
  351. End Sub
  352. Sub cFieldData_KeyDown (Index As Integer, KeyCode As Integer, Shift As Integer)
  353.   If KeyCode = &H73 Then   'F4
  354.     cFieldName_DblClick Index
  355.   ElseIf KeyCode = 34 And cScrollBar.Visible = True Then
  356.     'pagedown with > 10 fields
  357.     cScrollBar = cScrollBar - 3000
  358.   ElseIf KeyCode = 33 And cScrollBar.Visible = True Then
  359.     'pageup with > 10 fields
  360.     cScrollBar = cScrollBar + 3000
  361.   End If
  362. End Sub
  363. Sub cFieldData_KeyPress (Index As Integer, KeyAscii As Integer)
  364.   'only allow return when in edit of add mode
  365.   If FEditFlag = True Or FAddNewFlag = True Then
  366.     If FTBL(Index).Type = FT_STRING And Len(cFieldData(Index)) > FTBL(Index).Size Then
  367.       Beep
  368.       MsgBox "Field Length Exceeded!", 48
  369.       KeyAscii = 0
  370.       Exit Sub
  371.     End If
  372.     If KeyAscii = 13 Then
  373.       KeyAscii = 0
  374.       SendKeys "{Tab}"
  375.     End If
  376.   'throw away the keystrokes if not in add or edit mode
  377.   ElseIf FEditFlag = False And FAddNewFlag = False Then
  378.     KeyAscii = 0
  379.   End If
  380. End Sub
  381. Sub cFieldData_LostFocus (Index As Integer)
  382.   On Error GoTo FldDataErr
  383.   If FFldDataChanged = True Then
  384.     'store the data in the field
  385.     FTBL(Index) = cFieldData(Index)
  386.   End If
  387.   GoTo FldDataEnd
  388. FldDataErr:
  389.   ShowError
  390.   Resume FldDataEnd
  391. FldDataEnd:
  392.   'reset for valid or error condition
  393.   FFldDataChanged = False
  394. End Sub
  395. Sub cFieldName_DblClick (Index As Integer)
  396.   On Error GoTo ZoomErr
  397.   If FTBL(Index).Type = FT_STRING Or FTBL(Index).Type = FT_MEMO Then
  398.      If FTBL(Index).FieldSize() < GETCHUNK_CUTOFF Then
  399.        gstZoomData = cFieldData(Index)
  400.      Else
  401.        'add the rest of the field data with getchunk
  402.        MsgBar "Getting Memo Field Data", True
  403.        SetHourglass Me
  404.        gstZoomData = cFieldData(Index) + StripNonAscii(FTBL(Index).GetChunk(GETCHUNK_CUTOFF, MAX_MEMO_SIZE))
  405.        ResetMouse Me
  406.        MsgBar "", False
  407.      End If
  408.      fZoom.Caption = Mid(cFieldName(Index), 1, Len(cFieldName(Index)) - 1)
  409.      fZoom.Top = Top + 1200
  410.      fZoom.Left = Left + 250
  411.      If FAddNewFlag Or FEditFlag Then
  412.        fZoom.SaveButton.Visible = True
  413.        fZoom.CloseButton.Visible = True
  414.      Else
  415.        fZoom.CloseZoomButton.Visible = True
  416.      End If
  417.      fZoom.Show MODAL
  418.      If FAddNewFlag Or FEditFlag Then
  419.        If FTBL(Index).Type = FT_STRING And Len(gstZoomData) > FTBL(Index).Size Then
  420.          Beep
  421.          MsgBox "Field Length Exceeded, Data Truncated!", 48
  422.          cFieldData(Index) = Mid(gstZoomData, 1, FTBL(Index).Size)
  423.        Else
  424.          cFieldData(Index) = gstZoomData
  425.        End If
  426.        FTBL(Index) = cFieldData(Index)
  427.        FFldDataChanged = False
  428.      End If
  429.   End If
  430.   GoTo ZoomEnd
  431. ZoomErr:
  432.   ShowError
  433.   Resume ZoomEnd
  434. ZoomEnd:
  435. End Sub
  436. Sub cIndexes_Click ()
  437.   On Error GoTo IndErr
  438.   If FTBL Is Nothing Then Exit Sub
  439.   If FTBL.Index = Mid(cIndexes, 1, InStr(1, cIndexes, ":") - 1) Then Exit Sub
  440.   FTBL.Index = Mid(cIndexes, 1, InStr(1, cIndexes, ":") - 1)
  441.   FCurrRec = 1
  442.   DisplayCurrentRecord
  443.   FAtTop = True
  444.   GoTo IndEnd
  445. IndErr:
  446.   ShowError
  447.   Resume IndEnd
  448. IndEnd:
  449. End Sub
  450. Sub ClearDataFields ()
  451.   Dim i As Integer
  452.   'clear out the fields on the main form
  453.   For i = 0 To FTBL.Fields.Count - 1
  454.     cFieldData(i) = ""
  455.   Next
  456. End Sub
  457. Sub CloseButton_Click ()
  458.   Unload Me
  459. End Sub
  460. Sub cScrollBar_Change ()
  461.   Dim t As Integer
  462.   t = cScrollBar
  463.   If (t - 960) Mod 300 = 0 Then
  464.     cFields.Top = t
  465.   Else
  466.     cFields.Top = ((t - 960) \ 300) * 300 + 960
  467.   End If
  468. End Sub
  469. Sub DelButton_Click ()
  470.   On Error GoTo DelRecErr
  471.   If MsgBox("Delete Current Record?", MSGBOX_TYPE) = YES Then
  472.     FTBL.Delete
  473.     If gfTransPending Then gfDBChanged = True
  474.     If FTBL.EOF = False Then
  475.       FTBL.MoveNext
  476.     End If
  477.     FNumbRows = FNumbRows - 1
  478.     DisplayCurrentRecord
  479.   End If
  480.   GoTo DelRecEnd
  481. DelRecErr:
  482.   ShowError
  483.   Resume DelRecEnd
  484. DelRecEnd:
  485. End Sub
  486. Sub DisplayCurrentRecord ()
  487.    Dim i As Integer
  488.    Dim cst As String    'current status bar
  489.    Dim currstr As String
  490.    On Error GoTo DCRErr
  491.    SetHourglass Me
  492.    If FCurrRec = -1 And FTBL.RecordCount = 0 Then
  493.      currstr = "?"
  494.    Else
  495.      currstr = CStr(FCurrRec)
  496.    End If
  497.    cst = "Record "
  498.    'check BOF/EOF flag so we know if we
  499.    'are sitting on a valid record
  500.    If FAddNewFlag = True Then
  501.      cst = cst + currstr + " of " + CStr(FNumbRows)
  502.    Else
  503.      If FTBL.BOF = True Then
  504.        FCurrRec = 0
  505.        cst = cst + "(BOF) of " + CStr(FNumbRows)
  506.        ClearDataFields
  507.      ElseIf FTBL.EOF = True Then
  508.        FCurrRec = FNumbRows + 1
  509.        cst = cst + "(EOF) of " + CStr(FNumbRows)
  510.        ClearDataFields
  511.      Else
  512.        cst = cst + currstr + " of " + CStr(FNumbRows)
  513.        'place the data in the form fields
  514.        For i = 0 To FTBL.Fields.Count - 1
  515.          If FTBL(i).Type = FT_MEMO Then
  516.            If FTBL(i).FieldSize() < GETCHUNK_CUTOFF Then
  517.              cFieldData(i) = StripNonAscii(vFieldVal(FTBL(i)))
  518.            Else
  519.              cFieldData(i) = StripNonAscii(vFieldVal(FTBL(i).GetChunk(0, GETCHUNK_CUTOFF)))
  520.            End If
  521.          ElseIf FTBL(i).Type = FT_STRING Then
  522.            cFieldData(i) = StripNonAscii(vFieldVal(FTBL(i)))
  523.          Else
  524.            cFieldData(i) = vFieldVal(FTBL(i))
  525.          End If
  526.        Next
  527.      End If
  528.    End If
  529.    If gfUpdatable = False Then cst = cst + "  [Not Updatable]"
  530.    cStatusBar = cst
  531.    'set the flag
  532.    FFldDataChanged = False
  533.    GoTo DCREnd
  534. DCRErr:
  535.   ShowError
  536.   Resume DCREnd
  537. DCREnd:
  538.    ResetMouse Me
  539. End Sub
  540. Sub EditButton_Click ()
  541.    On Error GoTo EditErr
  542.    FTBL.Edit
  543.    cStatusBar = "Edit record"
  544.    FEditFlag = True
  545.    cFieldData(0).SetFocus
  546.    FBM = FTBL.Bookmark
  547.    ChangeButtons.Visible = True
  548.    ViewButtons.Visible = False
  549.    NextButton.Enabled = False
  550.    FirstButton.Enabled = False
  551.    LastButton.Enabled = False
  552.    PrevButton.Enabled = False
  553.    GoTo EditEnd
  554. EditErr:
  555.   ShowError
  556.   Resume EditEnd
  557. EditEnd:
  558. End Sub
  559. Sub FilterButton_Click ()
  560.   On Error GoTo FilterErr
  561.   Dim FilterStr As String
  562.   Dim f As New fDynaset
  563.   FilterStr = InputBox("Enter Filter Expression:")
  564.   If FilterStr = "" Then Exit Sub
  565.   gstTableDynaFilter = "select * from " + FTblName + " where " + FilterStr
  566.   f.Show                           'open dynaset form w/ filtered table
  567.   gstTableDynaFilter = ""
  568.   GoTo FilterEnd
  569. FilterErr:
  570.   ShowError
  571.   Resume FilterEnd
  572. FilterEnd:
  573. End Sub
  574. Sub FirstButton_Click ()
  575.    Dim ds As String
  576.    On Error GoTo GoFirstError
  577.    FTBL.MoveFirst
  578.    FCurrRec = 1
  579.    DisplayCurrentRecord
  580.    FAtTop = True
  581.    GoTo GoFirstEnd
  582. GoFirstError:
  583.    ShowError
  584.    Resume GoFirstEnd
  585. GoFirstEnd:
  586.    ResetMouse Me
  587.    MsgBar "", False
  588. End Sub
  589. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  590.   If FEditFlag = True Or FAddNewFlag = True Then Exit Sub
  591.   Select Case KeyCode
  592.     Case 35                'end
  593.       Call LastButton_Click
  594.     Case 36                'home
  595.       Call FirstButton_Click
  596.     Case 38                'up arrow
  597.       If Shift = 2 Then
  598.         Call FirstButton_Click
  599.       Else
  600.         Call PrevButton_Click
  601.       End If
  602.     Case 40                'down arrow
  603.       If Shift = 2 Then
  604.         Call LastButton_Click
  605.       Else
  606.         Call NextButton_Click
  607.       End If
  608.   End Select
  609. End Sub
  610. Sub Form_Load ()
  611.    Dim ft As Integer
  612.    Dim i As Integer
  613.    Dim tbl As tabledef
  614.    Dim istr As String
  615.    On Error GoTo TableErr
  616.    SetHourglass Me
  617.    MsgBar "Opening Table", True
  618.    FTblName = fTables.cTableList
  619.    Set tbl = gCurrentDB.TableDefs(FTblName)
  620.    For i = 0 To tbl.Indexes.Count - 1
  621.      istr = tbl.Indexes(i).Name
  622.      istr = istr + ":" + tbl.Indexes(i).Fields
  623.      If tbl.Indexes(i).Unique = True Then
  624.        istr = istr + ":Unique"
  625.      Else
  626.        istr = istr + ":Non-Unique"
  627.      End If
  628.      If tbl.Indexes(i).Primary = True Then
  629.        istr = istr + ":Primary"
  630.      End If
  631.      cIndexes.AddItem istr
  632.    Next
  633.    Set FTBL = gCurrentDB.OpenTable(FTblName)
  634.    'show the first record
  635.    FNumbRows = GetNumbRecsTbl(FTBL)          'query numb of recs
  636.    'load the controls on the Table form
  637.    cFieldName(0).Visible = True
  638.    cFieldData(0).Visible = True
  639.    ft = FTBL(0).Type
  640.    cFieldData(0).Width = GetFieldWidth(ft)
  641.    cFieldData(0).TabIndex = 0
  642.    For i = 1 To FTBL.Fields.Count - 1
  643.      cFields.Height = cFields.Height + 300
  644.      Load cFieldName(i)
  645.      cFieldName(i).Top = cFieldName(i - 1).Top + 300
  646.      cFieldName(i).Visible = True
  647.      Load cFieldData(i)
  648.      cFieldData(i).Top = cFieldData(i - 1).Top + 300
  649.      cFieldData(i).Visible = True
  650.      ft = FTBL.Fields(i).Type
  651.      cFieldData(i).Width = GetFieldWidth(ft)
  652.      cFieldData(i).TabIndex = i
  653.    Next
  654.    'resize main window
  655.    If i <= 10 Then
  656.      Height = ((i + 1) * 300) + 1600
  657.    Else
  658.      Height = 4668
  659.      Width = Width + 260
  660.      cScrollBar.Visible = True
  661.      cScrollBar.Min = 900
  662.      cScrollBar.Max = 900 - (i * 300) + 3000
  663.    End If
  664.    'display the field names
  665.    For i = 0 To FTBL.Fields.Count - 1
  666.      cFieldName(i) = UCase(FTBL(i).Name) + ":"
  667.    Next
  668.    FCurrRec = 1
  669.    If cIndexes.ListCount > 0 Then
  670.      cIndexes.ListIndex = 0
  671.    End If
  672.    DisplayCurrentRecord      'display field values
  673.    FAtTop = True
  674.    Caption = "Table: " + FTblName
  675.    Width = 5805
  676.    Left = 1000
  677.    Top = 1000
  678.    GoTo OkayEnd
  679. TableErr:
  680.    ShowError
  681.    ResetMouse Me
  682.    Unload Me
  683.    MsgBar "", False
  684.    Exit Sub
  685.    Resume OkayEnd
  686. OkayEnd:
  687.    ResetMouse Me
  688.    MsgBar "", False
  689. End Sub
  690. Sub Form_Paint ()
  691.   Outlines Me
  692. End Sub
  693. Sub Form_Resize ()
  694.   On Error Resume Next
  695.   Dim h As Integer, i As Integer
  696.   Dim totw As Integer
  697.   If WindowState <> 1 Then   'not minimized
  698.     MsgBar "Resizing Form", True
  699.     'make sure the form is lined up on a field
  700.     h = Height
  701.     If (h - 1660) Mod 300 <> 0 Then
  702.       Height = ((h - 1660) \ 300) * 300 + 1660
  703.     End If
  704.     'resize the status bar
  705.     StatBox.Top = Height - 650
  706.     'resize the scrollbar
  707.     cScrollBar.Height = StatBox.Top - (ViewButtons.Top - FieldHeader.Height) - 1200
  708.     cScrollBar.Left = Width - 360
  709.     If FTBL.Fields.Count > 10 Then
  710.       cFields.Width = Width - 260
  711.       totw = cScrollBar.Left - 20
  712.     Else
  713.       cFields.Width = Width - 20
  714.       totw = Width - 50
  715.     End If
  716.     FieldHeader.Width = Width - 20
  717.     'widen the fields if possible
  718.     For i = 0 To FTBL.Fields.Count - 1
  719.       cFieldName(i).Width = .3 * totw
  720.       cFieldData(i).Left = cFieldName(i).Width + 20
  721.       If FTBL(i).Type = FT_STRING Or FTBL(i).Type = FT_MEMO Then
  722.         cFieldData(i).Width = .7 * totw - 250
  723.       End If
  724.     Next
  725.     FieldValueLabel.Left = cFieldData(0).Left
  726.     cStatusBar.Width = Width - 1600
  727.     NextButton.Left = cStatusBar.Width + 745
  728.     LastButton.Left = NextButton.Left + 370
  729.   End If
  730.   MsgBar "", False
  731. End Sub
  732. Sub Form_Unload (Cancel As Integer)
  733.   On Error Resume Next
  734.   Unload FSeekForm   'get rid of attached seek form
  735.   FTBL.Close          'close the form Table
  736.   MsgBar "", False
  737. End Sub
  738. Sub LastButton_Click ()
  739.    On Error GoTo GoLastError
  740.    FTBL.MoveLast
  741.    'show the current record
  742.    FCurrRec = FNumbRows
  743.    DisplayCurrentRecord
  744.    GoTo GoLastEnd
  745. GoLastError:
  746.    ShowError
  747.    Resume GoLastEnd
  748. GoLastEnd:
  749. End Sub
  750. Sub NextButton_Click ()
  751.    On Error GoTo GoNextError
  752.    FTBL.MoveNext
  753.    'show the current record
  754.    If FCurrRec <> -1 Then
  755.      FCurrRec = FCurrRec + 1   'bump the record counter
  756.    End If
  757.    DisplayCurrentRecord
  758.    FAtTop = False
  759.    GoTo GoNextEnd
  760. GoNextError:
  761.    ShowError
  762.    Resume GoNextEnd
  763. GoNextEnd:
  764. End Sub
  765. Sub PrevButton_Click ()
  766.    On Error GoTo GoPrevError
  767.    FTBL.MovePrevious
  768.    'show the current record
  769.    If FCurrRec <> -1 Then
  770.      FCurrRec = FCurrRec - 1   'bump the record counter back
  771.    End If
  772.    DisplayCurrentRecord
  773.    FAtTop = False
  774.    GoTo GoPrevEnd
  775. GoPrevError:
  776.    ShowError
  777.    Resume GoPrevEnd
  778. GoPrevEnd:
  779. End Sub
  780. Sub PropButton_Click ()
  781.    Dim f As New fDataBox
  782.    On Error GoTo DynPropErr
  783.    Set gCurrentTbl = FTBL
  784.    f.Caption = "Table Properties"
  785.    f.Tag = "TBL"
  786.    f.cData.AddItem "Name = " + FTBL.Name
  787.    f.cData.AddItem "BOF Flag = " + stTrueFalse((FTBL.BOF))
  788.    f.cData.AddItem "BookMark = " + FTBL.Bookmark
  789.    f.cData.AddItem "BookMarkable Flag = " + stTrueFalse((FTBL.Bookmarkable))
  790.    f.cData.AddItem "Date Created = " + FTBL.DateCreated
  791.    f.cData.AddItem "EOF Flag = " + stTrueFalse((FTBL.EOF))
  792.    f.cData.AddItem "Index = " + FTBL.Index
  793.    f.cData.AddItem "Last Modified = " + FTBL.LastModified
  794.    f.cData.AddItem "Last Updated = " + FTBL.LastUpdated
  795.    f.cData.AddItem "Lock Edits Flag = " + stTrueFalse((FTBL.LockEdits))
  796.    f.cData.AddItem "No Match Flag = " + stTrueFalse((FTBL.NoMatch))
  797.    f.cData.AddItem "Transactions Flag = " + stTrueFalse((FTBL.Transactions))
  798.    f.cData.AddItem "RecordCount = " & FTBL.RecordCount
  799.    f.cData.AddItem "Updatable Flag = " + stTrueFalse((FTBL.Updatable))
  800.    f.Show MODAL
  801.   GoTo DynPropEnd
  802. DynPropErr:
  803.   f.cData.AddItem Error$
  804.   Resume Next
  805. DynPropEnd:
  806. End Sub
  807. Sub SeekButton_Click ()
  808.   On Error GoTo SeekErr
  809.   Dim bm As String
  810.   If FTBL.RecordCount = 0 Then Exit Sub
  811. SeekStart:
  812.   MsgBar "Enter Seek Parameters", False
  813.   fSeek.Show MODAL
  814.   If gstSeekValue = "" Then GoTo SeekEnd
  815.   bm = FTBL.Bookmark
  816.   SetHourglass Me
  817.   FTBL.Seek gstSeekOperator, gstSeekValue
  818.   ResetMouse Me
  819.   'return to old record if no match was found
  820.   If FTBL.NoMatch And bm <> "" Then
  821.     Beep
  822.     MsgBox "Record Not Found", 48
  823.     FTBL.Bookmark = bm
  824.     GoTo SeekStart
  825.   Else
  826.     If FCurrRec <> -1 Then
  827.       MsgBox "Current Record Number cannot be retained after Seek!"
  828.     End If
  829.     FCurrRec = -1  'set to -1 because it is no longer valid
  830.   End If
  831.   DisplayCurrentRecord
  832.   GoTo SeekEnd
  833. SeekErr:
  834.   ResetMouse Me
  835.   MsgBox Error$
  836.   Resume SeekEnd
  837. SeekEnd:
  838.   MsgBar "", False
  839. End Sub
  840. Sub UpdateButton_Click ()
  841.   On Error GoTo UpdateErr
  842.   FTBL.Update
  843.   If gfTransPending Then gfDBChanged = True
  844.   If FAddNewFlag = True Then
  845.     FNumbRows = FNumbRows + 1
  846.     FCurrRec = FNumbRows
  847.     FTBL.MoveLast               'move to the new record
  848.   End If
  849.   FEditFlag = False
  850.   FAddNewFlag = False
  851.   ChangeButtons.Visible = False
  852.   ViewButtons.Visible = True
  853.   NextButton.Enabled = True
  854.   FirstButton.Enabled = True
  855.   LastButton.Enabled = True
  856.   PrevButton.Enabled = True
  857.   DisplayCurrentRecord
  858.   GoTo UpdateEnd
  859. UpdateErr:
  860.   ShowError
  861.   Resume UpdateEnd
  862. UpdateEnd:
  863. End Sub
  864.