home *** CD-ROM | disk | FTP | other *** search
/ Master 95 #1 / MASTER95_1.iso / microsof / vbasic4 / vb4-6.cab / tableobj.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-26  |  24.4 KB  |  779 lines

  1. VERSION 4.00
  2. Begin VB.Form frmTableObj 
  3.    ClientHeight    =   3495
  4.    ClientLeft      =   1335
  5.    ClientTop       =   2625
  6.    ClientWidth     =   5685
  7.    Height          =   3900
  8.    HelpContextID   =   2016145
  9.    Icon            =   "TABLEOBJ.frx":0000
  10.    KeyPreview      =   -1  'True
  11.    Left            =   1275
  12.    LinkTopic       =   "Form1"
  13.    LockControls    =   -1  'True
  14.    MDIChild        =   -1  'True
  15.    ScaleHeight     =   3480
  16.    ScaleMode       =   0  'User
  17.    ScaleWidth      =   5705.42
  18.    Tag             =   "Recordset"
  19.    Top             =   2280
  20.    Width           =   5805
  21.    Begin VB.PictureBox picViewButtons 
  22.       Align           =   1  'Align Top
  23.       Appearance      =   0  'Flat
  24.       BorderStyle     =   0  'None
  25.       ForeColor       =   &H80000008&
  26.       Height          =   705
  27.       Left            =   0
  28.       ScaleHeight     =   705
  29.       ScaleMode       =   0  'User
  30.       ScaleWidth      =   5688.392
  31.       TabIndex        =   1
  32.       TabStop         =   0   'False
  33.       Top             =   0
  34.       Width           =   5685
  35.       Begin VB.ComboBox cboIndexes 
  36.          BackColor       =   &H00FFFFFF&
  37.          Height          =   300
  38.          Left            =   720
  39.          Style           =   2  'Dropdown List
  40.          TabIndex        =   9
  41.          Top             =   360
  42.          Width           =   4335
  43.       End
  44.       Begin VB.CommandButton cmdSeek 
  45.          Caption         =   "&Seek"
  46.          Height          =   330
  47.          Left            =   2280
  48.          TabIndex        =   5
  49.          Top             =   0
  50.          Width           =   750
  51.       End
  52.       Begin VB.CommandButton cmdFilter 
  53.          Caption         =   "F&ilter"
  54.          Height          =   330
  55.          Left            =   3000
  56.          TabIndex        =   6
  57.          Top             =   0
  58.          Width           =   750
  59.       End
  60.       Begin VB.CommandButton cmdClose 
  61.          Cancel          =   -1  'True
  62.          Caption         =   "&Close"
  63.          Height          =   330
  64.          Left            =   4425
  65.          TabIndex        =   8
  66.          TabStop         =   0   'False
  67.          Top             =   0
  68.          Width           =   750
  69.       End
  70.       Begin VB.CommandButton cmdProp 
  71.          Caption         =   "&Prop"
  72.          Height          =   330
  73.          Left            =   3720
  74.          TabIndex        =   7
  75.          Top             =   0
  76.          Width           =   750
  77.       End
  78.       Begin VB.CommandButton cmdDelete 
  79.          Caption         =   "&Delete"
  80.          Height          =   330
  81.          Left            =   1560
  82.          TabIndex        =   4
  83.          Top             =   0
  84.          Width           =   750
  85.       End
  86.       Begin VB.CommandButton cmdEdit 
  87.          Caption         =   "&Edit"
  88.          Height          =   330
  89.          Left            =   840
  90.          TabIndex        =   3
  91.          Top             =   0
  92.          Width           =   750
  93.       End
  94.       Begin VB.CommandButton cmdAdd 
  95.          Caption         =   "&Add"
  96.          Height          =   330
  97.          Left            =   0
  98.          TabIndex        =   2
  99.          Top             =   0
  100.          Width           =   870
  101.       End
  102.       Begin VB.Label lblIndex 
  103.          Caption         =   "Index:"
  104.          Height          =   255
  105.          Left            =   120
  106.          TabIndex        =   25
  107.          Top             =   400
  108.          Width           =   615
  109.       End
  110.    End
  111.    Begin VB.PictureBox picFieldHeader 
  112.       Appearance      =   0  'Flat
  113.       BorderStyle     =   0  'None
  114.       ForeColor       =   &H80000008&
  115.       Height          =   240
  116.       Left            =   0
  117.       ScaleHeight     =   240
  118.       ScaleMode       =   0  'User
  119.       ScaleWidth      =   14948.92
  120.       TabIndex        =   22
  121.       Top             =   705
  122.       Width           =   14946
  123.       Begin VB.Label lblFieldValue 
  124.          Caption         =   " Value  (F4=Zoom) "
  125.          Height          =   255
  126.          Left            =   1680
  127.          TabIndex        =   24
  128.          Top             =   0
  129.          Width           =   3165
  130.       End
  131.       Begin VB.Label lblFieldHdr 
  132.          Caption         =   "Field Name:"
  133.          Height          =   252
  134.          Left            =   120
  135.          TabIndex        =   23
  136.          Top             =   0
  137.          Width           =   1212
  138.       End
  139.    End
  140.    Begin VB.PictureBox picChangeButtons 
  141.       BorderStyle     =   0  'None
  142.       Height          =   690
  143.       Left            =   0
  144.       ScaleHeight     =   690
  145.       ScaleMode       =   0  'User
  146.       ScaleWidth      =   5658.375
  147.       TabIndex        =   14
  148.       TabStop         =   0   'False
  149.       Top             =   0
  150.       Visible         =   0   'False
  151.       Width           =   5655
  152.       Begin VB.CommandButton cmdUpdate 
  153.          Caption         =   "&Update"
  154.          Height          =   372
  155.          Left            =   960
  156.          TabIndex        =   16
  157.          Top             =   48
  158.          Width           =   1212
  159.       End
  160.       Begin VB.CommandButton cmdCancel 
  161.          Caption         =   "&Cancel"
  162.          Height          =   372
  163.          Left            =   2640
  164.          TabIndex        =   15
  165.          Top             =   48
  166.          Width           =   1212
  167.       End
  168.    End
  169.    Begin VB.PictureBox picStatBox 
  170.       Align           =   2  'Align Bottom
  171.       Appearance      =   0  'Flat
  172.       BorderStyle     =   0  'None
  173.       ForeColor       =   &H80000008&
  174.       Height          =   285
  175.       Left            =   0
  176.       ScaleHeight     =   298.153
  177.       ScaleMode       =   0  'User
  178.       ScaleWidth      =   5695.241
  179.       TabIndex        =   20
  180.       TabStop         =   0   'False
  181.       Top             =   3210
  182.       Width           =   5685
  183.       Begin VB.CommandButton cmdNext 
  184.          Caption         =   ">"
  185.          Height          =   287
  186.          Left            =   4200
  187.          TabIndex        =   12
  188.          Top             =   0
  189.          Width           =   375
  190.       End
  191.       Begin VB.CommandButton cmdLast 
  192.          Caption         =   ">|"
  193.          Height          =   287
  194.          Left            =   4575
  195.          TabIndex        =   13
  196.          Top             =   0
  197.          Width           =   375
  198.       End
  199.       Begin VB.CommandButton cmdFirst 
  200.          Caption         =   "|<"
  201.          Height          =   287
  202.          Left            =   0
  203.          TabIndex        =   10
  204.          Top             =   0
  205.          Width           =   375
  206.       End
  207.       Begin VB.CommandButton cmdPrevious 
  208.          Caption         =   "<"
  209.          Height          =   287
  210.          Left            =   375
  211.          TabIndex        =   11
  212.          Top             =   0
  213.          Width           =   375
  214.       End
  215.       Begin VB.Label lblStatus 
  216.          BackColor       =   &H00FFFFFF&
  217.          BorderStyle     =   1  'Fixed Single
  218.          Height          =   285
  219.          Left            =   735
  220.          TabIndex        =   21
  221.          Top             =   0
  222.          Width           =   3360
  223.       End
  224.    End
  225.    Begin VB.VScrollBar vsbScrollBar 
  226.       Height          =   2616
  227.       LargeChange     =   3000
  228.       Left            =   5040
  229.       SmallChange     =   300
  230.       TabIndex        =   19
  231.       Top             =   960
  232.       Visible         =   0   'False
  233.       Width           =   252
  234.    End
  235.    Begin VB.PictureBox picFields 
  236.       Appearance      =   0  'Flat
  237.       BorderStyle     =   0  'None
  238.       ForeColor       =   &H80000008&
  239.       Height          =   375
  240.       Left            =   120
  241.       ScaleHeight     =   372
  242.       ScaleMode       =   0  'User
  243.       ScaleWidth      =   4812
  244.       TabIndex        =   17
  245.       TabStop         =   0   'False
  246.       Top             =   960
  247.       Width           =   4815
  248.       Begin VB.TextBox txtFieldData 
  249.          BackColor       =   &H00FFFFFF&
  250.          DataSource      =   "Data1"
  251.          ForeColor       =   &H00000000&
  252.          Height          =   288
  253.          Index           =   0
  254.          Left            =   1560
  255.          TabIndex        =   0
  256.          Top             =   0
  257.          Visible         =   0   'False
  258.          Width           =   3252
  259.       End
  260.       Begin VB.Label lblFieldName 
  261.          Height          =   252
  262.          Index           =   0
  263.          Left            =   0
  264.          TabIndex        =   18
  265.          Top             =   60
  266.          Visible         =   0   'False
  267.          Width           =   1572
  268.       End
  269.    End
  270. Attribute VB_Name = "frmTableObj"
  271. Attribute VB_Creatable = False
  272. Attribute VB_Exposed = False
  273. Option Explicit
  274. 'form variables
  275. Dim mrecFormTable As Recordset   'current form's table
  276. Dim msTableName As String        'form recordset table name
  277. Dim msBookMark As String         'form bookmark
  278. Dim mbEditFlag As Integer        'edit mode
  279. Dim mbAddNewFlag As Integer      'add mode
  280. Dim mbDataChanged As Integer
  281. Dim mfrmSeek As New frmSeek      'seek form instance
  282. Dim mlNumRows As Long            'total rows in Table
  283. Private Sub cmdAdd_Click()
  284.   On Error GoTo AddErr
  285.   'set the mode
  286.   mrecFormTable.AddNew
  287.   lblStatus.Caption = "Add record"
  288.   mbAddNewFlag = True
  289.   If mrecFormTable.RecordCount > 0 Then
  290.     msBookMark = mrecFormTable.Bookmark
  291.   Else
  292.     msBookMark = gsNULL_STR
  293.   End If
  294.   picChangeButtons.Visible = True
  295.   picViewButtons.Visible = False
  296.   cmdNext.Enabled = False
  297.   cmdFirst.Enabled = False
  298.   cmdLast.Enabled = False
  299.   cmdPrevious.Enabled = False
  300.   ClearDataFields Me, mrecFormTable.Fields.Count
  301.   txtFieldData(0).SetFocus
  302.   Exit Sub
  303. AddErr:
  304.   ShowError
  305.   Exit Sub
  306. End Sub
  307. Private Sub cmdCancel_Click()
  308.    On Error Resume Next
  309.    picChangeButtons.Visible = False
  310.    picViewButtons.Visible = True
  311.    cmdNext.Enabled = True
  312.    cmdFirst.Enabled = True
  313.    cmdLast.Enabled = True
  314.    cmdPrevious.Enabled = True
  315.    mbEditFlag = False
  316.    mbAddNewFlag = False
  317.    If Len(msBookMark) > 0 Then mrecFormTable.Bookmark = msBookMark
  318.    DisplayCurrentRecord Me, mrecFormTable, mlNumRows, mbAddNewFlag
  319.    mbDataChanged = False
  320.    DBEngine.Idle dbFreeLocks
  321. End Sub
  322. Private Sub txtFieldData_Change(Index As Integer)
  323.   'just set the flag if data is changed
  324.   'it gets reset to false when a new record is displayed
  325.   mbDataChanged = True
  326. End Sub
  327. Private Sub txtFieldData_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
  328.   If KeyCode = &H73 Then   'F4
  329.     lblFieldName_DblClick Index
  330.   ElseIf KeyCode = 34 And vsbScrollBar.Visible = True Then
  331.     'pagedown with > 10 fields
  332.     vsbScrollBar.Value = vsbScrollBar.Value - 3000
  333.   ElseIf KeyCode = 33 And vsbScrollBar.Visible = True Then
  334.     'pageup with > 10 fields
  335.     vsbScrollBar.Value = vsbScrollBar.Value + 3000
  336.   End If
  337. End Sub
  338. Private Sub txtFieldData_KeyPress(Index As Integer, KeyAscii As Integer)
  339.   'only allow return when in edit of add mode
  340.   If mbEditFlag = True Or mbAddNewFlag = True Then
  341.     If KeyAscii = 13 Then
  342.       KeyAscii = 0
  343.       SendKeys "{Tab}"
  344.     End If
  345.   'throw away the keystrokes if not in add or edit mode
  346.   ElseIf mbEditFlag = False And mbAddNewFlag = False Then
  347.     KeyAscii = 0
  348.   End If
  349. End Sub
  350. Private Sub txtFieldData_LostFocus(Index As Integer)
  351.   On Error GoTo FldDataErr
  352.   If mbDataChanged = True Then
  353.     'store the data in the field
  354.     mrecFormTable(Index) = txtFieldData(Index)
  355.   End If
  356.   'reset for valid or error condition
  357.   mbDataChanged = False
  358.   Exit Sub
  359. FldDataErr:
  360.   ShowError
  361.   mbDataChanged = False
  362.   Exit Sub
  363. End Sub
  364. Private Sub lblFieldName_DblClick(Index As Integer)
  365.   On Error GoTo ZoomErr
  366.   If mrecFormTable(Index).Type = dbText Or mrecFormTable(Index).Type = dbMemo Then
  367.      If mrecFormTable(Index).Type = dbText Then
  368.        gsZoomData = txtFieldData(Index).Text
  369.      ElseIf mrecFormTable(Index).FieldSize() < gnGETCHUNK_CUTOFF Then
  370.        gsZoomData = txtFieldData(Index).Text
  371.      Else
  372.        'add the rest of the field data with getchunk
  373.        MsgBar "Getting Memo Field Data", True
  374.        SetHourglass
  375.        gsZoomData = txtFieldData(Index).Text & StripNonAscii(mrecFormTable(Index).GetChunk(gnGETCHUNK_CUTOFF, gnMAX_MEMO_SIZE))
  376.        Screen.MousePointer = vbDefault
  377.        MsgBar gsNULL_STR, False
  378.      End If
  379.      frmZoom.Caption = Mid(lblFieldName(Index).Caption, 1, Len(lblFieldName(Index).Caption) - 1)
  380.      frmZoom.Top = Top + 1200
  381.      frmZoom.Left = Left + 250
  382.      If mbAddNewFlag Or mbEditFlag Then
  383.        frmZoom.cmdSave.Visible = True
  384.        frmZoom.cmdCloseNoSave.Visible = True
  385.      Else
  386.        frmZoom.cmdClose.Visible = True
  387.      End If
  388.      If mrecFormTable(Index).Type = dbText Then
  389.        frmZoom.txtZoomData.Text = gsZoomData
  390.        frmZoom.Height = 1125
  391.      Else
  392.        frmZoom.txtMemo.Text = gsZoomData
  393.        frmZoom.txtMemo.Visible = True
  394.        frmZoom.txtZoomData.Visible = False
  395.        frmZoom.Height = 2205
  396.      End If
  397.      frmZoom.Show vbModal
  398.      If (mbAddNewFlag Or mbEditFlag) And gsZoomData <> "__CANCELLED__" Then
  399.        If mrecFormTable(Index).Type = dbText And Len(gsZoomData) > mrecFormTable(Index).Size Then
  400.          Beep
  401.          MsgBox "Field Length Exceeded, Data Truncated!", 48
  402.          txtFieldData(Index).Text = Mid(gsZoomData, 1, mrecFormTable(Index).Size)
  403.        Else
  404.          txtFieldData(Index).Text = gsZoomData
  405.        End If
  406.        mrecFormTable(Index) = txtFieldData(Index).Text
  407.        mbDataChanged = False
  408.      End If
  409.   End If
  410.   Exit Sub
  411. ZoomErr:
  412.   ShowError
  413.   Exit Sub
  414. End Sub
  415. Private Sub cboIndexes_Click()
  416.   On Error GoTo IndErr
  417.   If mrecFormTable Is Nothing Then Exit Sub
  418.   If mrecFormTable.Index = Mid(cboIndexes.Text, 1, InStr(1, cboIndexes.Text, ":") - 1) Then Exit Sub
  419.   mrecFormTable.Index = Mid(cboIndexes.Text, 1, InStr(1, cboIndexes.Text, ":") - 1)
  420.   DisplayCurrentRecord Me, mrecFormTable, mlNumRows, mbAddNewFlag
  421.   mbDataChanged = False
  422.   Exit Sub
  423. IndErr:
  424.   ShowError
  425.   Exit Sub
  426. End Sub
  427. Private Sub cmdClose_Click()
  428.   Unload Me
  429. End Sub
  430. Private Sub vsbScrollBar_Change()
  431.   Dim nTop As Integer
  432.   nTop = vsbScrollBar
  433.   If (nTop - 960) Mod gnCTLARRAYHEIGHT = 0 Then
  434.     picFields.Top = nTop
  435.   Else
  436.     picFields.Top = ((nTop - 960) \ gnCTLARRAYHEIGHT) * gnCTLARRAYHEIGHT + 960
  437.   End If
  438. End Sub
  439. Private Sub cmdDelete_Click()
  440.   On Error GoTo DelRecErr
  441.   If MsgBox("Delete Current Record?", gnMSGBOX_TYPE) = gnMSGBOX_YES Then
  442.     mrecFormTable.Delete
  443.     If gbTransPending Then gbDBChanged = True
  444.     If mrecFormTable.EOF = False Then
  445.       mrecFormTable.MoveNext
  446.     End If
  447.     mlNumRows = mlNumRows - 1
  448.     DisplayCurrentRecord Me, mrecFormTable, mlNumRows, mbAddNewFlag
  449.     mbDataChanged = False
  450.   End If
  451.   Exit Sub
  452. DelRecErr:
  453.   ShowError
  454.   Exit Sub
  455. End Sub
  456. Private Sub cmdEdit_Click()
  457.    On Error GoTo EditErr
  458.   Dim nDelay As Long
  459.   Dim nRetryCnt As Integer
  460.   SetHourglass
  461. RetryEdit:
  462.    mrecFormTable.Edit
  463.    lblStatus.Caption = "Edit record"
  464.    mbEditFlag = True
  465.    txtFieldData(0).SetFocus
  466.    msBookMark = mrecFormTable.Bookmark
  467.    picChangeButtons.Visible = True
  468.    picViewButtons.Visible = False
  469.    cmdNext.Enabled = False
  470.    cmdFirst.Enabled = False
  471.    cmdLast.Enabled = False
  472.    cmdPrevious.Enabled = False
  473.    Screen.MousePointer = vbDefault
  474.    Exit Sub
  475. EditErr:
  476.   If Err = 3260 And nRetryCnt < gnMURetryCnt Then
  477.     nRetryCnt = nRetryCnt + 1
  478.     DBEngine.Idle dbFreeLocks
  479.     'Wait gnMUDelay seconds
  480.     nDelay = Timer
  481.     While Timer - nDelay < gnMUDelay
  482.       'do nothing
  483.     Wend
  484.     Resume RetryEdit
  485.   Else
  486.     ShowError
  487.     Exit Sub
  488.   End If
  489. End Sub
  490. Private Sub cmdFilter_Click()
  491.   On Error GoTo FilterErr
  492.   Dim sFilter As String
  493.   Dim frmDyn As New frmDynaSnap
  494.   sFilter = InputBox("Enter Filter Expression:")
  495.   If Len(sFilter) = 0 Then Exit Sub
  496.   gsTableDynaFilter = "select * from " & AddBrackets(msTableName) & " where " & sFilter
  497.   frmDyn.Show                           'open recordset form w/ filtered table
  498.   gsTableDynaFilter = gsNULL_STR
  499.   Exit Sub
  500. FilterErr:
  501.   ShowError
  502.   Exit Sub
  503. End Sub
  504. Private Sub cmdFirst_Click()
  505.    On Error GoTo GoFirstError
  506.    mrecFormTable.MoveFirst
  507.    DisplayCurrentRecord Me, mrecFormTable, mlNumRows, mbAddNewFlag
  508.    mbDataChanged = False
  509.    Screen.MousePointer = vbDefault
  510.    MsgBar gsNULL_STR, False
  511.    Exit Sub
  512. GoFirstError:
  513.    ShowError
  514.    Exit Sub
  515. End Sub
  516. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  517.   If mbEditFlag = True Or mbAddNewFlag = True Then Exit Sub
  518.   Select Case KeyCode
  519.     Case 35                'end
  520.       Call cmdLast_Click
  521.     Case 36                'home
  522.       Call cmdFirst_Click
  523.     Case 38                'up arrow
  524.       If Shift = 2 Then
  525.         Call cmdFirst_Click
  526.       Else
  527.         Call cmdPrevious_Click
  528.       End If
  529.     Case 40                'down arrow
  530.       If Shift = 2 Then
  531.         Call cmdLast_Click
  532.       Else
  533.         Call cmdNext_Click
  534.       End If
  535.   End Select
  536. End Sub
  537. Private Sub Form_Load()
  538.    Dim nFieldType As Integer
  539.    Dim i As Integer
  540.    Dim tdf As TableDef
  541.    Dim idx As Index
  542.    Dim sIndex As String
  543.    On Error GoTo TableErr
  544.    SetHourglass
  545.    MsgBar "Opening Table", True
  546.    msTableName = StripConnect(frmTables.lstTables.Text)
  547.    Set tdf = gdbCurrentDB.TableDefs(msTableName)
  548.    For Each idx In tdf.Indexes
  549.      sIndex = idx.Name
  550.      sIndex = sIndex & ":" & idx.Fields
  551.      If idx.UNIQUE = True Then
  552.        sIndex = sIndex & ":Unique"
  553.      Else
  554.        sIndex = sIndex & ":Non-Unique"
  555.      End If
  556.      If idx.PRIMARY = True Then
  557.        sIndex = sIndex & ":Primary"
  558.      End If
  559.      cboIndexes.AddItem sIndex
  560.    Next
  561.    Set mrecFormTable = gdbCurrentDB.OpenRecordset(msTableName, dbOpenTable)
  562.    'set the locking type
  563.    If gsDataType = gsJETMDB Then
  564.      mrecFormTable.LockEdits = gnMULocking
  565.    End If
  566.    'show the first record
  567.    mlNumRows = GetNumbRecs(mrecFormTable)
  568.    'load the controls on the Table form
  569.    lblFieldName(0).Visible = True
  570.    txtFieldData(0).Visible = True
  571.    nFieldType = mrecFormTable.Fields(0).Type
  572.    txtFieldData(0).Width = GetFieldWidth(nFieldType)
  573.    txtFieldData(0).TabIndex = 0
  574.    If nFieldType = dbText Then txtFieldData(0).MaxLength = mrecFormTable.Fields(0).Size
  575.    For i = 1 To mrecFormTable.Fields.Count - 1
  576.      picFields.Height = picFields.Height + gnCTLARRAYHEIGHT
  577.      Load lblFieldName(i)
  578.      lblFieldName(i).Top = lblFieldName(i - 1).Top + gnCTLARRAYHEIGHT
  579.      lblFieldName(i).Visible = True
  580.      Load txtFieldData(i)
  581.      txtFieldData(i).Top = txtFieldData(i - 1).Top + gnCTLARRAYHEIGHT
  582.      txtFieldData(i).Visible = True
  583.      nFieldType = mrecFormTable.Fields(i).Type
  584.      txtFieldData(i).Width = GetFieldWidth(nFieldType)
  585.      txtFieldData(i).TabIndex = i
  586.      If nFieldType = dbText Then txtFieldData(i).MaxLength = mrecFormTable(i).Size
  587.    Next
  588.    'resize main window
  589.    If i <= 10 Then
  590.      Me.Height = ((i + 1) * gnCTLARRAYHEIGHT) + 1600
  591.    Else
  592.      Me.Height = 4668
  593.      Me.Width = Me.Width + 260
  594.      vsbScrollBar.Visible = True
  595.      vsbScrollBar.Min = 900
  596.      vsbScrollBar.Max = 900 - (i * gnCTLARRAYHEIGHT&) + 2500
  597.    End If
  598.    'display the field names
  599.    For i = 0 To mrecFormTable.Fields.Count - 1
  600.      lblFieldName(i).Caption = mrecFormTable(i).Name & ":"
  601.    Next
  602.    If cboIndexes.ListCount > 0 Then
  603.      cboIndexes.ListIndex = 0
  604.    Else
  605.      DisplayCurrentRecord Me, mrecFormTable, mlNumRows, mbAddNewFlag
  606.      mbDataChanged = False
  607.    End If
  608.    Me.Caption = "Table: " & msTableName
  609.    Me.Width = 5805
  610.    Me.Left = 1000
  611.    Me.Top = 1000
  612.    Screen.MousePointer = vbDefault
  613.    MsgBar gsNULL_STR, False
  614.    Exit Sub
  615. TableErr:
  616.    ShowError
  617.    Unload Me
  618.    Exit Sub
  619. End Sub
  620. Private Sub Form_Resize()
  621.   On Error Resume Next
  622.   Dim nHeight As Integer
  623.   Dim i As Integer
  624.   Dim nTotWidth As Integer
  625.   If WindowState <> 1 Then   'not minimized
  626.     MsgBar "Resizing Form", True
  627.     'make sure the form is lined up on a field
  628.     nHeight = Me.Height
  629.     If (nHeight - 1660) Mod gnCTLARRAYHEIGHT <> 0 Then
  630.       Me.Height = ((nHeight - 1660) \ gnCTLARRAYHEIGHT) * gnCTLARRAYHEIGHT + 1660
  631.     End If
  632.     'resize the status bar
  633.     picStatBox.Top = Me.Height - 650
  634.     'resize the scrollbar
  635.     vsbScrollBar.Height = picStatBox.Top - (picViewButtons.Top - picFieldHeader.Height) - 1200
  636.     vsbScrollBar.Left = Me.Width - 360
  637.     If mrecFormTable.Fields.Count > 10 Then
  638.       picFields.Width = Me.Width - 260
  639.       nTotWidth = vsbScrollBar.Left - 20
  640.     Else
  641.       picFields.Width = Me.Width - 20
  642.       nTotWidth = Me.Width - 50
  643.     End If
  644.     picFieldHeader.Width = Me.Width - 20
  645.     'widen the fields if possible
  646.     For i = 0 To mrecFormTable.Fields.Count - 1
  647.       lblFieldName(i).Width = 0.3 * nTotWidth
  648.       txtFieldData(i).Left = lblFieldName(i).Width + 20
  649.       If mrecFormTable(i).Type = dbText Or mrecFormTable(i).Type = dbMemo Then
  650.         txtFieldData(i).Width = 0.7 * nTotWidth - 250
  651.       End If
  652.     Next
  653.     lblFieldValue.Left = txtFieldData(0).Left
  654.     lblStatus.Width = Me.Width - 1600
  655.     cmdNext.Left = lblStatus.Width + 745
  656.     cmdLast.Left = cmdNext.Left + 370
  657.   End If
  658.   MsgBar gsNULL_STR, False
  659. End Sub
  660. Private Sub Form_Unload(Cancel As Integer)
  661.   On Error Resume Next
  662.   Unload mfrmSeek   'get rid of attached seek form
  663.   mrecFormTable.Close          'close the form Table
  664.   DBEngine.Idle dbFreeLocks
  665.   MsgBar gsNULL_STR, False
  666. End Sub
  667. Private Sub cmdLast_Click()
  668.    On Error GoTo GoLastError
  669.    mrecFormTable.MoveLast
  670.    'show the current record
  671.    DisplayCurrentRecord Me, mrecFormTable, mlNumRows, mbAddNewFlag
  672.    mbDataChanged = False
  673.    Exit Sub
  674. GoLastError:
  675.    ShowError
  676.    Exit Sub
  677. End Sub
  678. Private Sub cmdNext_Click()
  679.    On Error GoTo GoNextError
  680.    mrecFormTable.MoveNext
  681.    'show the current record
  682.    DisplayCurrentRecord Me, mrecFormTable, mlNumRows, mbAddNewFlag
  683.    mbDataChanged = False
  684.    Exit Sub
  685. GoNextError:
  686.    ShowError
  687.    Exit Sub
  688. End Sub
  689. Private Sub cmdPrevious_Click()
  690.    On Error GoTo GoPrevError
  691.    mrecFormTable.MovePrevious
  692.    'show the current record
  693.    DisplayCurrentRecord Me, mrecFormTable, mlNumRows, mbAddNewFlag
  694.    mbDataChanged = False
  695.    Exit Sub
  696. GoPrevError:
  697.    ShowError
  698.    Exit Sub
  699. End Sub
  700. Private Sub cmdProp_Click()
  701.   ShowProperties "Table", mrecFormTable
  702. End Sub
  703. Private Sub cmdSeek_Click()
  704.   On Error GoTo SeekErr
  705.   Dim sBookMark As String
  706.   If mrecFormTable.RecordCount = 0 Then Exit Sub
  707. SeekStart:
  708.   MsgBar "Enter Seek Parameters", False
  709.   frmSeek.Show vbModal
  710.   If Len(gsSeekValue) = 0 Then
  711.     MsgBar gsNULL_STR, False
  712.     Exit Sub
  713.   End If
  714.   sBookMark = mrecFormTable.Bookmark
  715.   SetHourglass
  716.   mrecFormTable.Seek gsSeekOperator, gsSeekValue
  717.   Screen.MousePointer = vbDefault
  718.   'return to old record if no match was found
  719.   If mrecFormTable.NoMatch And Len(sBookMark) > 0 Then
  720.     Beep
  721.     MsgBox "Record Not Found", 48
  722.     mrecFormTable.Bookmark = sBookMark
  723.     GoTo SeekStart
  724.   End If
  725.   DisplayCurrentRecord Me, mrecFormTable, mlNumRows, mbAddNewFlag
  726.   mbDataChanged = False
  727.   MsgBar gsNULL_STR, False
  728.   Exit Sub
  729. SeekErr:
  730.   Screen.MousePointer = vbDefault
  731.   MsgBox Error
  732.   Exit Sub
  733. End Sub
  734. Sub txtFieldData_MouseUp(Index As Integer, Button As Integer, Shift As Integer, x As Single, Y As Single)
  735.   If Button <> 2 Then Exit Sub
  736.   ShowProperties "Field", mrecFormTable.Fields(Index)
  737. End Sub
  738. Private Sub cmdUpdate_Click()
  739.   On Error GoTo UpdateErr
  740.   Dim nDelay As Long
  741.   Dim nRetryCnt As Integer
  742.   SetHourglass
  743. RetryUpd:
  744.   mrecFormTable.Update
  745.   If gbTransPending Then gbDBChanged = True
  746.   If mbAddNewFlag = True Then
  747.     mlNumRows = mlNumRows + 1
  748.     mrecFormTable.MoveLast               'move to the new record
  749.   End If
  750.   mbEditFlag = False
  751.   mbAddNewFlag = False
  752.   picChangeButtons.Visible = False
  753.   picViewButtons.Visible = True
  754.   cmdNext.Enabled = True
  755.   cmdFirst.Enabled = True
  756.   cmdLast.Enabled = True
  757.   cmdPrevious.Enabled = True
  758.   DisplayCurrentRecord Me, mrecFormTable, mlNumRows, mbAddNewFlag
  759.   mbDataChanged = False
  760.   DBEngine.Idle dbFreeLocks
  761.   Screen.MousePointer = vbDefault
  762.   Exit Sub
  763. UpdateErr:
  764.   If Err = 3260 And nRetryCnt < gnMURetryCnt Then
  765.     nRetryCnt = nRetryCnt + 1
  766.     mrecFormTable.Bookmark = mrecFormTable.Bookmark   'Cancel the update
  767.     DBEngine.Idle dbFreeLocks
  768.     nDelay = Timer
  769.     'Wait gnMUDelay seconds
  770.     While Timer - nDelay < gnMUDelay
  771.       'do nothing
  772.     Wend
  773.     Resume RetryUpd
  774.   Else
  775.     ShowError
  776.     Exit Sub
  777.   End If
  778. End Sub
  779.