home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / PVb5.0 / VB / SAMPLES / VISDATA / TABLEOBJ.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-01-12  |  29.0 KB  |  920 lines

  1. VERSION 5.00
  2. Begin VB.Form frmTableObj 
  3.    ClientHeight    =   3495
  4.    ClientLeft      =   1335
  5.    ClientTop       =   2625
  6.    ClientWidth     =   5580
  7.    HelpContextID   =   2016145
  8.    Icon            =   "TABLEOBJ.frx":0000
  9.    KeyPreview      =   -1  'True
  10.    LinkTopic       =   "Form1"
  11.    LockControls    =   -1  'True
  12.    MDIChild        =   -1  'True
  13.    ScaleHeight     =   3480
  14.    ScaleMode       =   0  'User
  15.    ScaleWidth      =   5593.989
  16.    ShowInTaskbar   =   0   'False
  17.    Tag             =   "Recordset"
  18.    Begin VB.PictureBox picViewButtons 
  19.       Align           =   1  'Align Top
  20.       Appearance      =   0  'Flat
  21.       BorderStyle     =   0  'None
  22.       ForeColor       =   &H80000008&
  23.       Height          =   705
  24.       Left            =   0
  25.       ScaleHeight     =   705
  26.       ScaleMode       =   0  'User
  27.       ScaleWidth      =   5577.292
  28.       TabIndex        =   1
  29.       TabStop         =   0   'False
  30.       Top             =   0
  31.       Width           =   5580
  32.       Begin VB.ComboBox cboIndexes 
  33.          BackColor       =   &H00FFFFFF&
  34.          BeginProperty Font 
  35.             Name            =   "
  36.             Size            =   9
  37.             Charset         =   134
  38.             Weight          =   400
  39.             Underline       =   0   'False
  40.             Italic          =   0   'False
  41.             Strikethrough   =   0   'False
  42.          EndProperty
  43.          Height          =   315
  44.          Left            =   720
  45.          Style           =   2  'Dropdown List
  46.          TabIndex        =   8
  47.          Top             =   360
  48.          Width           =   4335
  49.       End
  50.       Begin VB.CommandButton cmdSeek 
  51.          Caption         =   "
  52. (&S)"
  53.          BeginProperty Font 
  54.             Name            =   "
  55.             Size            =   9
  56.             Charset         =   134
  57.             Weight          =   400
  58.             Underline       =   0   'False
  59.             Italic          =   0   'False
  60.             Strikethrough   =   0   'False
  61.          EndProperty
  62.          Height          =   330
  63.          Left            =   2835
  64.          TabIndex        =   5
  65.          Top             =   0
  66.          Width           =   900
  67.       End
  68.       Begin VB.CommandButton cmdFilter 
  69.          Caption         =   "
  70. (&I)"
  71.          BeginProperty Font 
  72.             Name            =   "
  73.             Size            =   9
  74.             Charset         =   134
  75.             Weight          =   400
  76.             Underline       =   0   'False
  77.             Italic          =   0   'False
  78.             Strikethrough   =   0   'False
  79.          EndProperty
  80.          Height          =   330
  81.          Left            =   3735
  82.          TabIndex        =   6
  83.          Top             =   0
  84.          Width           =   900
  85.       End
  86.       Begin VB.CommandButton cmdClose 
  87.          Cancel          =   -1  'True
  88.          Caption         =   "
  89. (&C)"
  90.          BeginProperty Font 
  91.             Name            =   "
  92.             Size            =   9
  93.             Charset         =   134
  94.             Weight          =   400
  95.             Underline       =   0   'False
  96.             Italic          =   0   'False
  97.             Strikethrough   =   0   'False
  98.          EndProperty
  99.          Height          =   330
  100.          Left            =   4644
  101.          TabIndex        =   7
  102.          TabStop         =   0   'False
  103.          Top             =   0
  104.          Width           =   900
  105.       End
  106.       Begin VB.CommandButton cmdDelete 
  107.          Caption         =   "
  108. (&D)"
  109.          BeginProperty Font 
  110.             Name            =   "
  111.             Size            =   9
  112.             Charset         =   134
  113.             Weight          =   400
  114.             Underline       =   0   'False
  115.             Italic          =   0   'False
  116.             Strikethrough   =   0   'False
  117.          EndProperty
  118.          Height          =   330
  119.          Left            =   1935
  120.          TabIndex        =   4
  121.          Top             =   0
  122.          Width           =   900
  123.       End
  124.       Begin VB.CommandButton cmdEdit 
  125.          Caption         =   "
  126. (&E)"
  127.          BeginProperty Font 
  128.             Name            =   "
  129.             Size            =   9
  130.             Charset         =   134
  131.             Weight          =   400
  132.             Underline       =   0   'False
  133.             Italic          =   0   'False
  134.             Strikethrough   =   0   'False
  135.          EndProperty
  136.          Height          =   330
  137.          Left            =   1020
  138.          TabIndex        =   3
  139.          Top             =   0
  140.          Width           =   900
  141.       End
  142.       Begin VB.CommandButton cmdAdd 
  143.          Caption         =   "
  144. (&A)"
  145.          BeginProperty Font 
  146.             Name            =   "
  147.             Size            =   9
  148.             Charset         =   134
  149.             Weight          =   400
  150.             Underline       =   0   'False
  151.             Italic          =   0   'False
  152.             Strikethrough   =   0   'False
  153.          EndProperty
  154.          Height          =   330
  155.          Left            =   0
  156.          TabIndex        =   2
  157.          Top             =   0
  158.          Width           =   1020
  159.       End
  160.       Begin VB.Label lblIndex 
  161.          Caption         =   "
  162.          BeginProperty Font 
  163.             Name            =   "
  164.             Size            =   9
  165.             Charset         =   134
  166.             Weight          =   400
  167.             Underline       =   0   'False
  168.             Italic          =   0   'False
  169.             Strikethrough   =   0   'False
  170.          EndProperty
  171.          Height          =   255
  172.          Left            =   120
  173.          TabIndex        =   24
  174.          Top             =   400
  175.          Width           =   615
  176.       End
  177.    End
  178.    Begin VB.PictureBox picFieldHeader 
  179.       Appearance      =   0  'Flat
  180.       BorderStyle     =   0  'None
  181.       ForeColor       =   &H80000008&
  182.       Height          =   240
  183.       Left            =   0
  184.       ScaleHeight     =   240
  185.       ScaleMode       =   0  'User
  186.       ScaleWidth      =   14948.92
  187.       TabIndex        =   21
  188.       Top             =   705
  189.       Width           =   14946
  190.       Begin VB.Label lblFieldValue 
  191.          Caption         =   "
  192.          BeginProperty Font 
  193.             Name            =   "
  194.             Size            =   9
  195.             Charset         =   134
  196.             Weight          =   400
  197.             Underline       =   0   'False
  198.             Italic          =   0   'False
  199.             Strikethrough   =   0   'False
  200.          EndProperty
  201.          Height          =   255
  202.          Left            =   1680
  203.          TabIndex        =   23
  204.          Top             =   0
  205.          Width           =   3165
  206.       End
  207.       Begin VB.Label lblFieldHdr 
  208.          Caption         =   "
  209.          BeginProperty Font 
  210.             Name            =   "
  211.             Size            =   9
  212.             Charset         =   134
  213.             Weight          =   400
  214.             Underline       =   0   'False
  215.             Italic          =   0   'False
  216.             Strikethrough   =   0   'False
  217.          EndProperty
  218.          Height          =   252
  219.          Left            =   120
  220.          TabIndex        =   22
  221.          Top             =   0
  222.          Width           =   1212
  223.       End
  224.    End
  225.    Begin VB.PictureBox picChangeButtons 
  226.       BorderStyle     =   0  'None
  227.       Height          =   690
  228.       Left            =   0
  229.       ScaleHeight     =   690
  230.       ScaleMode       =   0  'User
  231.       ScaleWidth      =   5658.375
  232.       TabIndex        =   13
  233.       TabStop         =   0   'False
  234.       Top             =   0
  235.       Visible         =   0   'False
  236.       Width           =   5655
  237.       Begin VB.CommandButton cmdUpdate 
  238.          Caption         =   "
  239. (&U)"
  240.          BeginProperty Font 
  241.             Name            =   "
  242.             Size            =   9
  243.             Charset         =   134
  244.             Weight          =   400
  245.             Underline       =   0   'False
  246.             Italic          =   0   'False
  247.             Strikethrough   =   0   'False
  248.          EndProperty
  249.          Height          =   372
  250.          Left            =   960
  251.          TabIndex        =   15
  252.          Top             =   48
  253.          Width           =   1212
  254.       End
  255.       Begin VB.CommandButton cmdCancel 
  256.          Caption         =   "
  257. (&C)"
  258.          BeginProperty Font 
  259.             Name            =   "
  260.             Size            =   9
  261.             Charset         =   134
  262.             Weight          =   400
  263.             Underline       =   0   'False
  264.             Italic          =   0   'False
  265.             Strikethrough   =   0   'False
  266.          EndProperty
  267.          Height          =   372
  268.          Left            =   2640
  269.          TabIndex        =   14
  270.          Top             =   48
  271.          Width           =   1212
  272.       End
  273.    End
  274.    Begin VB.PictureBox picStatBox 
  275.       Align           =   2  'Align Bottom
  276.       Appearance      =   0  'Flat
  277.       BorderStyle     =   0  'None
  278.       ForeColor       =   &H80000008&
  279.       Height          =   285
  280.       Left            =   0
  281.       ScaleHeight     =   298.153
  282.       ScaleMode       =   0  'User
  283.       ScaleWidth      =   5584.009
  284.       TabIndex        =   19
  285.       TabStop         =   0   'False
  286.       Top             =   3204
  287.       Width           =   5580
  288.       Begin VB.CommandButton cmdNext 
  289.          Caption         =   ">"
  290.          Height          =   287
  291.          Left            =   4200
  292.          TabIndex        =   11
  293.          Top             =   0
  294.          Width           =   375
  295.       End
  296.       Begin VB.CommandButton cmdLast 
  297.          Caption         =   ">|"
  298.          Height          =   287
  299.          Left            =   4575
  300.          TabIndex        =   12
  301.          Top             =   0
  302.          Width           =   375
  303.       End
  304.       Begin VB.CommandButton cmdFirst 
  305.          Caption         =   "|<"
  306.          Height          =   287
  307.          Left            =   0
  308.          TabIndex        =   9
  309.          Top             =   0
  310.          Width           =   375
  311.       End
  312.       Begin VB.CommandButton cmdPrevious 
  313.          Caption         =   "<"
  314.          Height          =   287
  315.          Left            =   375
  316.          TabIndex        =   10
  317.          Top             =   0
  318.          Width           =   375
  319.       End
  320.       Begin VB.Label lblStatus 
  321.          BackColor       =   &H00FFFFFF&
  322.          BorderStyle     =   1  'Fixed Single
  323.          BeginProperty Font 
  324.             Name            =   "
  325.             Size            =   9
  326.             Charset         =   134
  327.             Weight          =   400
  328.             Underline       =   0   'False
  329.             Italic          =   0   'False
  330.             Strikethrough   =   0   'False
  331.          EndProperty
  332.          Height          =   285
  333.          Left            =   735
  334.          TabIndex        =   20
  335.          Top             =   0
  336.          Width           =   3360
  337.       End
  338.    End
  339.    Begin VB.VScrollBar vsbScrollBar 
  340.       Height          =   2616
  341.       LargeChange     =   3000
  342.       Left            =   5040
  343.       SmallChange     =   300
  344.       TabIndex        =   18
  345.       Top             =   960
  346.       Visible         =   0   'False
  347.       Width           =   252
  348.    End
  349.    Begin VB.PictureBox picFields 
  350.       Appearance      =   0  'Flat
  351.       BorderStyle     =   0  'None
  352.       ForeColor       =   &H80000008&
  353.       Height          =   375
  354.       Left            =   120
  355.       ScaleHeight     =   372
  356.       ScaleMode       =   0  'User
  357.       ScaleWidth      =   4812
  358.       TabIndex        =   16
  359.       TabStop         =   0   'False
  360.       Top             =   960
  361.       Width           =   4815
  362.       Begin VB.TextBox txtFieldData 
  363.          BackColor       =   &H00FFFFFF&
  364.          DataSource      =   "Data1"
  365.          BeginProperty Font 
  366.             Name            =   "
  367.             Size            =   9
  368.             Charset         =   134
  369.             Weight          =   400
  370.             Underline       =   0   'False
  371.             Italic          =   0   'False
  372.             Strikethrough   =   0   'False
  373.          EndProperty
  374.          ForeColor       =   &H00000000&
  375.          Height          =   288
  376.          Index           =   0
  377.          Left            =   1560
  378.          TabIndex        =   0
  379.          Top             =   0
  380.          Visible         =   0   'False
  381.          Width           =   3252
  382.       End
  383.       Begin VB.Label lblFieldName 
  384.          BeginProperty Font 
  385.             Name            =   "
  386.             Size            =   9
  387.             Charset         =   134
  388.             Weight          =   400
  389.             Underline       =   0   'False
  390.             Italic          =   0   'False
  391.             Strikethrough   =   0   'False
  392.          EndProperty
  393.          Height          =   252
  394.          Index           =   0
  395.          Left            =   0
  396.          TabIndex        =   17
  397.          Top             =   60
  398.          Visible         =   0   'False
  399.          Width           =   1572
  400.       End
  401.    End
  402. Attribute VB_Name = "frmTableObj"
  403. Attribute VB_GlobalNameSpace = False
  404. Attribute VB_Creatable = False
  405. Attribute VB_PredeclaredId = True
  406. Attribute VB_Exposed = False
  407. Option Explicit
  408. '>>>>>>>>>>>>>>>>>>>>>>>>
  409. Const BUTTON1 = "
  410. (&A)"
  411. Const BUTTON2 = "
  412. (&E)"
  413. Const BUTTON3 = "
  414. (&D)"
  415. Const BUTTON4 = "
  416. (&C)"
  417. Const BUTTON5 = "
  418. (&S)"
  419. Const BUTTON6 = "
  420. (&I)"
  421. Const BUTTON7 = "
  422. (&C)"
  423. Const BUTTON8 = "
  424. (&U)"
  425. Const Label1 = "
  426. Const Label2 = "
  427. Const MSG1 = "
  428. Const MSG2 = "
  429. Const MSG3 = "
  430. Const MSG4 = "
  431. Const MSG5 = "
  432. Const MSG6 = "
  433. Const MSG7 = "
  434. Const MSG8 = "
  435. Const MSG9 = "
  436. '>>>>>>>>>>>>>>>>>>>>>>>>
  437. Public mrsFormRecordset As Recordset
  438. Dim msTableName As String        '
  439. Dim mvBookMark As Variant         '
  440. Dim mbEditFlag As Integer        '
  441. Dim mbAddNewFlag As Integer      '
  442. Dim mbDataChanged As Integer
  443. Dim mfrmSeek As New frmSeek      '
  444. Dim mlNumRows As Long            '
  445. Private Sub cmdAdd_Click()
  446.   On Error GoTo AddErr
  447.   mrsFormRecordset.AddNew
  448.   lblStatus.Caption = MSG1
  449.   mbAddNewFlag = True
  450.   If mrsFormRecordset.RecordCount > 0 Then
  451.     mvBookMark = mrsFormRecordset.Bookmark
  452.   Else
  453.     mvBookMark = vbNullString
  454.   End If
  455.   picChangeButtons.Visible = True
  456.   picViewButtons.Visible = False
  457.   cmdNext.Enabled = False
  458.   cmdFirst.Enabled = False
  459.   cmdLast.Enabled = False
  460.   cmdPrevious.Enabled = False
  461.   ClearDataFields Me, mrsFormRecordset.Fields.Count
  462.   txtFieldData(0).SetFocus
  463.   Exit Sub
  464. AddErr:
  465.   ShowError
  466. End Sub
  467. Private Sub cmdCancel_Click()
  468.    On Error Resume Next
  469.    picChangeButtons.Visible = False
  470.    picViewButtons.Visible = True
  471.    cmdNext.Enabled = True
  472.    cmdFirst.Enabled = True
  473.    cmdLast.Enabled = True
  474.    cmdPrevious.Enabled = True
  475.    mbEditFlag = False
  476.    mbAddNewFlag = False
  477.    If Len(mvBookMark) > 0 Then mrsFormRecordset.Bookmark = mvBookMark
  478.    DisplayCurrentRecord Me, mrsFormRecordset, mlNumRows, mbAddNewFlag
  479.    mbDataChanged = False
  480.    DBEngine.Idle dbFreeLocks
  481. End Sub
  482. Private Sub txtFieldData_Change(Index As Integer)
  483.  false
  484.   mbDataChanged = True
  485. End Sub
  486. Private Sub txtFieldData_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
  487.   If KeyCode = &H73 Then   'F4
  488.     lblFieldName_DblClick Index
  489.   ElseIf KeyCode = 34 And vsbScrollBar.Visible Then
  490.     '
  491.  > 10 
  492.     vsbScrollBar.Value = vsbScrollBar.Value - 3000
  493.   ElseIf KeyCode = 33 And vsbScrollBar.Visible Then
  494.     '
  495.  > 10 
  496.     vsbScrollBar.Value = vsbScrollBar.Value + 3000
  497.   End If
  498. End Sub
  499. Private Sub txtFieldData_KeyPress(Index As Integer, KeyAscii As Integer)
  500.   If mbEditFlag Or mbAddNewFlag Then
  501.     If KeyAscii = 13 Then
  502.       KeyAscii = 0
  503.       SendKeys "{Tab}"
  504.     End If
  505.   ElseIf mbEditFlag = False And mbAddNewFlag = False Then
  506.     KeyAscii = 0
  507.   End If
  508. End Sub
  509. Private Sub txtFieldData_LostFocus(Index As Integer)
  510.   On Error GoTo FldDataErr
  511.   If mbDataChanged Then
  512.     '
  513.     mrsFormRecordset(Index) = txtFieldData(Index)
  514.   End If
  515.   mbDataChanged = False
  516.   Exit Sub
  517. FldDataErr:
  518.   ShowError
  519.   mbDataChanged = False
  520. End Sub
  521. Private Sub lblFieldName_DblClick(Index As Integer)
  522.   On Error GoTo ZoomErr
  523.   If mrsFormRecordset(Index).Type = dbText Or mrsFormRecordset(Index).Type = dbMemo Then
  524.      If mrsFormRecordset(Index).Type = dbText Then
  525.        gsZoomData = txtFieldData(Index).Text
  526.      ElseIf mrsFormRecordset(Index).FieldSize() < gnGETCHUNK_CUTOFF Then
  527.        gsZoomData = txtFieldData(Index).Text
  528.      Else
  529.        '
  530.  getchunk 
  531.        MsgBar "Getting Memo Field Data", True
  532.        Screen.MousePointer = vbHourglass
  533.        gsZoomData = txtFieldData(Index).Text & StripNonAscii(mrsFormRecordset(Index).GetChunk(gnGETCHUNK_CUTOFF, gnMAX_MEMO_SIZE))
  534.        Screen.MousePointer = vbDefault
  535.        MsgBar vbNullString, False
  536.      End If
  537.      frmZoom.Caption = Mid(lblFieldName(Index).Caption, 1, Len(lblFieldName(Index).Caption) - 1)
  538.      frmZoom.Top = Top + 1200
  539.      frmZoom.Left = Left + 250
  540.      If mbAddNewFlag Or mbEditFlag Then
  541.        frmZoom.cmdSave.Visible = True
  542.        frmZoom.cmdCloseNoSave.Visible = True
  543.      Else
  544.        frmZoom.cmdClose.Visible = True
  545.      End If
  546.      If mrsFormRecordset(Index).Type = dbText Then
  547.        frmZoom.txtZoomData.Text = gsZoomData
  548.        frmZoom.Height = 1125
  549.      Else
  550.        frmZoom.txtMemo.Text = gsZoomData
  551.        frmZoom.txtMemo.Visible = True
  552.        frmZoom.txtZoomData.Visible = False
  553.        frmZoom.Height = 2205
  554.      End If
  555.      frmZoom.Show vbModal
  556.      If (mbAddNewFlag Or mbEditFlag) And gsZoomData <> "__CANCELLED__" Then
  557.        If mrsFormRecordset(Index).Type = dbText And Len(gsZoomData) > mrsFormRecordset(Index).Size Then
  558.          Beep
  559.          MsgBox MSG2, 48
  560.          txtFieldData(Index).Text = Mid(gsZoomData, 1, mrsFormRecordset(Index).Size)
  561.        Else
  562.          txtFieldData(Index).Text = gsZoomData
  563.        End If
  564.        mrsFormRecordset(Index) = txtFieldData(Index).Text
  565.        mbDataChanged = False
  566.      End If
  567.   End If
  568.   Exit Sub
  569. ZoomErr:
  570.   ShowError
  571. End Sub
  572. Private Sub cboIndexes_Click()
  573.   On Error GoTo IndErr
  574.   If mrsFormRecordset Is Nothing Then Exit Sub
  575.   If mrsFormRecordset.Index = Mid(cboIndexes.Text, 1, InStr(1, cboIndexes.Text, ":") - 1) Then Exit Sub
  576.   mrsFormRecordset.Index = Mid(cboIndexes.Text, 1, InStr(1, cboIndexes.Text, ":") - 1)
  577.   DisplayCurrentRecord Me, mrsFormRecordset, mlNumRows, mbAddNewFlag
  578.   mbDataChanged = False
  579.   Exit Sub
  580. IndErr:
  581.   ShowError
  582. End Sub
  583. Private Sub cmdClose_Click()
  584.   Unload Me
  585. End Sub
  586. Private Sub vsbScrollBar_Change()
  587.   Dim nTop As Integer
  588.   nTop = vsbScrollBar
  589.   If (nTop - 960) Mod gnCTLARRAYHEIGHT = 0 Then
  590.     picFields.Top = nTop
  591.   Else
  592.     picFields.Top = ((nTop - 960) \ gnCTLARRAYHEIGHT) * gnCTLARRAYHEIGHT + 960
  593.   End If
  594. End Sub
  595. Private Sub cmdDelete_Click()
  596.   On Error GoTo DelRecErr
  597.   If MsgBox(MSG3, vbYesNo + vbQuestion) = vbYes Then
  598.     mrsFormRecordset.Delete
  599.     If gbTransPending Then gbDBChanged = True
  600.     If mrsFormRecordset.EOF = False Then
  601.       mrsFormRecordset.MoveNext
  602.     End If
  603.     mlNumRows = mlNumRows - 1
  604.     DisplayCurrentRecord Me, mrsFormRecordset, mlNumRows, mbAddNewFlag
  605.     mbDataChanged = False
  606.   End If
  607.   Exit Sub
  608. DelRecErr:
  609.   ShowError
  610. End Sub
  611. Private Sub cmdEdit_Click()
  612.    On Error GoTo EditErr
  613.   Dim nDelay As Long
  614.   Dim nRetryCnt As Integer
  615.   Screen.MousePointer = vbHourglass
  616. RetryEdit:
  617.    mrsFormRecordset.Edit
  618.    lblStatus.Caption = MSG4
  619.    mbEditFlag = True
  620.    txtFieldData(0).SetFocus
  621.    mvBookMark = mrsFormRecordset.Bookmark
  622.    picChangeButtons.Visible = True
  623.    picViewButtons.Visible = False
  624.    cmdNext.Enabled = False
  625.    cmdFirst.Enabled = False
  626.    cmdLast.Enabled = False
  627.    cmdPrevious.Enabled = False
  628.    Screen.MousePointer = vbDefault
  629.    Exit Sub
  630. EditErr:
  631.   If Err = 3260 And nRetryCnt < gnMURetryCnt Then
  632.     nRetryCnt = nRetryCnt + 1
  633.     DBEngine.Idle dbFreeLocks
  634.     '
  635.  gnMUDelay 
  636.     nDelay = Timer
  637.     While Timer - nDelay < gnMUDelay
  638.       '
  639.     Wend
  640.     Resume RetryEdit
  641.   Else
  642.     ShowError
  643.   End If
  644. End Sub
  645. Private Sub cmdFilter_Click()
  646.   On Error GoTo FilterErr
  647.   Dim sFilter As String
  648.   Dim frmDyn As New frmDynaSnap
  649.   sFilter = InputBox(MSG5)
  650.   If Len(sFilter) = 0 Then Exit Sub
  651.   gsTableDynaFilter = "select * from " & AddBrackets(msTableName) & " where " & sFilter
  652.   frmDyn.Show                           '
  653.   gsTableDynaFilter = vbNullString
  654.   Exit Sub
  655. FilterErr:
  656.   ShowError
  657. End Sub
  658. Private Sub cmdFirst_Click()
  659.    On Error GoTo GoFirstError
  660.    mrsFormRecordset.MoveFirst
  661.    DisplayCurrentRecord Me, mrsFormRecordset, mlNumRows, mbAddNewFlag
  662.    mbDataChanged = False
  663.    Screen.MousePointer = vbDefault
  664.    MsgBar vbNullString, False
  665.    Exit Sub
  666. GoFirstError:
  667.    ShowError
  668. End Sub
  669. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  670.   If mbEditFlag Or mbAddNewFlag Then Exit Sub
  671.   Select Case KeyCode
  672.     Case 35                'end
  673.       Call cmdLast_Click
  674.     Case 36                'home
  675.       Call cmdFirst_Click
  676.     Case 38                '
  677.       If Shift = 2 Then
  678.         Call cmdFirst_Click
  679.       Else
  680.         Call cmdPrevious_Click
  681.       End If
  682.     Case 40                '
  683.       If Shift = 2 Then
  684.         Call cmdLast_Click
  685.       Else
  686.         Call cmdNext_Click
  687.       End If
  688.   End Select
  689. End Sub
  690. Private Sub Form_Load()
  691.    Dim nFieldType As Integer
  692.    Dim i As Integer
  693.    Dim tdf As TableDef
  694.    Dim idx As Index
  695.    Dim sIndex As String
  696.    On Error GoTo TableErr
  697.    cmdAdd.Caption = BUTTON1
  698.    cmdEdit.Caption = BUTTON2
  699.    cmdDelete.Caption = BUTTON3
  700.    cmdClose.Caption = BUTTON4
  701.    cmdSeek.Caption = BUTTON5
  702.    cmdFilter.Caption = BUTTON6
  703.    cmdCancel.Caption = BUTTON7
  704.    cmdUpdate.Caption = BUTTON8
  705.    lblFieldHdr.Caption = Label1
  706.    lblFieldValue.Caption = Label2
  707.    Screen.MousePointer = vbHourglass
  708.    MsgBar MSG6, True
  709.    msTableName = mrsFormRecordset.Name
  710.    Set tdf = gdbCurrentDB.TableDefs(msTableName)
  711.    For Each idx In tdf.Indexes
  712.      sIndex = idx.Name
  713.      sIndex = sIndex & ":" & idx.Fields
  714.      If idx.Unique Then
  715.        sIndex = sIndex & ":Unique"
  716.      Else
  717.        sIndex = sIndex & ":Non-Unique"
  718.      End If
  719.      If idx.Primary Then
  720.        sIndex = sIndex & ":Primary"
  721.      End If
  722.      cboIndexes.AddItem sIndex
  723.    Next
  724.    If gsDataType = gsMSACCESS Then
  725.      mrsFormRecordset.LockEdits = gnMULocking
  726.    End If
  727.    mlNumRows = mrsFormRecordset.RecordCount
  728.    lblFieldName(0).Visible = True
  729.    txtFieldData(0).Visible = True
  730.    nFieldType = mrsFormRecordset.Fields(0).Type
  731.    txtFieldData(0).Width = GetFieldWidth(nFieldType)
  732.    txtFieldData(0).TabIndex = 0
  733.    If nFieldType = dbText Then txtFieldData(0).MaxLength = mrsFormRecordset.Fields(0).Size
  734.    For i = 1 To mrsFormRecordset.Fields.Count - 1
  735.      picFields.Height = picFields.Height + gnCTLARRAYHEIGHT
  736.      Load lblFieldName(i)
  737.      lblFieldName(i).Top = lblFieldName(i - 1).Top + gnCTLARRAYHEIGHT
  738.      lblFieldName(i).Visible = True
  739.      Load txtFieldData(i)
  740.      txtFieldData(i).Top = txtFieldData(i - 1).Top + gnCTLARRAYHEIGHT
  741.      txtFieldData(i).Visible = True
  742.      nFieldType = mrsFormRecordset.Fields(i).Type
  743.      txtFieldData(i).Width = GetFieldWidth(nFieldType)
  744.      txtFieldData(i).TabIndex = i
  745.      If nFieldType = dbText Then txtFieldData(i).MaxLength = mrsFormRecordset(i).Size
  746.    Next
  747.    If i <= 10 Then
  748.      Me.Height = ((i + 1) * gnCTLARRAYHEIGHT) + 1600
  749.    Else
  750.      Me.Height = 4668
  751.      Me.Width = Me.Width + 260
  752.      vsbScrollBar.Visible = True
  753.      vsbScrollBar.Min = 900
  754.      vsbScrollBar.Max = 900 - (i * gnCTLARRAYHEIGHT&) + 2500
  755.    End If
  756.    For i = 0 To mrsFormRecordset.Fields.Count - 1
  757.      lblFieldName(i).Caption = mrsFormRecordset(i).Name & ":"
  758.    Next
  759.    If cboIndexes.ListCount > 0 Then
  760.      cboIndexes.ListIndex = 0
  761.    Else
  762.      DisplayCurrentRecord Me, mrsFormRecordset, mlNumRows, mbAddNewFlag
  763.      mbDataChanged = False
  764.    End If
  765.    Me.Width = 5508
  766.    Me.Left = 1000
  767.    Me.Top = 1000
  768.    Screen.MousePointer = vbDefault
  769.    MsgBar vbNullString, False
  770.    Exit Sub
  771. TableErr:
  772.    ShowError
  773.    Unload Me
  774. End Sub
  775. Private Sub Form_Resize()
  776.   On Error Resume Next
  777.   Dim nHeight As Integer
  778.   Dim i As Integer
  779.   Dim nTotWidth As Integer
  780.   If WindowState <> 1 Then   '
  781.     MsgBar MSG7, True
  782.     '
  783.     nHeight = Me.Height
  784.     If (nHeight - 1660) Mod gnCTLARRAYHEIGHT <> 0 Then
  785.       Me.Height = ((nHeight - 1660) \ gnCTLARRAYHEIGHT) * gnCTLARRAYHEIGHT + 1660
  786.     End If
  787.     '
  788.     picStatBox.Top = Me.Height - 650
  789.     '
  790.     vsbScrollBar.Height = picStatBox.Top - (picViewButtons.Top - picFieldHeader.Height) - 1200
  791.     vsbScrollBar.Left = Me.Width - 360
  792.     If mrsFormRecordset.Fields.Count > 10 Then
  793.       picFields.Width = Me.Width - 260
  794.       nTotWidth = vsbScrollBar.Left - 20
  795.     Else
  796.       picFields.Width = Me.Width - 20
  797.       nTotWidth = Me.Width - 50
  798.     End If
  799.     picFieldHeader.Width = Me.Width - 20
  800.     '
  801.     For i = 0 To mrsFormRecordset.Fields.Count - 1
  802.       lblFieldName(i).Width = 0.3 * nTotWidth
  803.       txtFieldData(i).Left = lblFieldName(i).Width + 20
  804.       If mrsFormRecordset(i).Type = dbText Or mrsFormRecordset(i).Type = dbMemo Then
  805.         txtFieldData(i).Width = 0.7 * nTotWidth - 250
  806.       End If
  807.     Next
  808.     lblFieldValue.Left = txtFieldData(0).Left
  809.     lblStatus.Width = Me.Width - 1600
  810.     cmdNext.Left = lblStatus.Width + 745
  811.     cmdLast.Left = cmdNext.Left + 370
  812.   End If
  813.   MsgBar vbNullString, False
  814. End Sub
  815. Private Sub Form_Unload(Cancel As Integer)
  816.   On Error Resume Next
  817.   Unload mfrmSeek   '
  818.   mrsFormRecordset.Close          '
  819.   DBEngine.Idle dbFreeLocks
  820.   MsgBar vbNullString, False
  821. End Sub
  822. Private Sub cmdLast_Click()
  823.    On Error GoTo GoLastError
  824.    mrsFormRecordset.MoveLast
  825.    DisplayCurrentRecord Me, mrsFormRecordset, mlNumRows, mbAddNewFlag
  826.    mbDataChanged = False
  827.    Exit Sub
  828. GoLastError:
  829.    ShowError
  830. End Sub
  831. Private Sub cmdNext_Click()
  832.    On Error GoTo GoNextError
  833.    mrsFormRecordset.MoveNext
  834.    DisplayCurrentRecord Me, mrsFormRecordset, mlNumRows, mbAddNewFlag
  835.    mbDataChanged = False
  836.    Exit Sub
  837. GoNextError:
  838.    ShowError
  839. End Sub
  840. Private Sub cmdPrevious_Click()
  841.    On Error GoTo GoPrevError
  842.    mrsFormRecordset.MovePrevious
  843.    DisplayCurrentRecord Me, mrsFormRecordset, mlNumRows, mbAddNewFlag
  844.    mbDataChanged = False
  845.    Exit Sub
  846. GoPrevError:
  847.    ShowError
  848. End Sub
  849. Private Sub cmdSeek_Click()
  850.   On Error GoTo SeekErr
  851.   Dim sBookMark As String
  852.   If mrsFormRecordset.RecordCount = 0 Then Exit Sub
  853. SeekStart:
  854.   MsgBar MSG8, False
  855.   frmSeek.Show vbModal
  856.   If Len(gsSeekValue) = 0 Then
  857.     MsgBar vbNullString, False
  858.     Exit Sub
  859.   End If
  860.   sBookMark = mrsFormRecordset.Bookmark
  861.   Screen.MousePointer = vbHourglass
  862.   mrsFormRecordset.Seek gsSeekOperator, gsSeekValue
  863.   Screen.MousePointer = vbDefault
  864.   If mrsFormRecordset.NoMatch And Len(sBookMark) > 0 Then
  865.     Beep
  866.     MsgBox MSG9, 48
  867.     mrsFormRecordset.Bookmark = sBookMark
  868.     GoTo SeekStart
  869.   End If
  870.   DisplayCurrentRecord Me, mrsFormRecordset, mlNumRows, mbAddNewFlag
  871.   mbDataChanged = False
  872.   MsgBar vbNullString, False
  873.   Exit Sub
  874. SeekErr:
  875.   Screen.MousePointer = vbDefault
  876.   MsgBox Error
  877.   Exit Sub
  878. End Sub
  879. Private Sub cmdUpdate_Click()
  880.   On Error GoTo UpdateErr
  881.   Dim nDelay As Long
  882.   Dim nRetryCnt As Integer
  883.   Screen.MousePointer = vbHourglass
  884. RetryUpd:
  885.   mrsFormRecordset.Update
  886.   If gbTransPending Then gbDBChanged = True
  887.   If mbAddNewFlag Then
  888.     mlNumRows = mlNumRows + 1
  889.     mrsFormRecordset.MoveLast               '
  890.   End If
  891.   mbEditFlag = False
  892.   mbAddNewFlag = False
  893.   picChangeButtons.Visible = False
  894.   picViewButtons.Visible = True
  895.   cmdNext.Enabled = True
  896.   cmdFirst.Enabled = True
  897.   cmdLast.Enabled = True
  898.   cmdPrevious.Enabled = True
  899.   DisplayCurrentRecord Me, mrsFormRecordset, mlNumRows, mbAddNewFlag
  900.   mbDataChanged = False
  901.   DBEngine.Idle dbFreeLocks
  902.   Screen.MousePointer = vbDefault
  903.   Exit Sub
  904. UpdateErr:
  905.   If Err = 3260 And nRetryCnt < gnMURetryCnt Then
  906.     nRetryCnt = nRetryCnt + 1
  907.     mrsFormRecordset.Bookmark = mrsFormRecordset.Bookmark   '
  908.     DBEngine.Idle dbFreeLocks
  909.     nDelay = Timer
  910.     '
  911.  gnMUDelay 
  912.     While Timer - nDelay < gnMUDelay
  913.       '
  914.     Wend
  915.     Resume RetryUpd
  916.   Else
  917.     ShowError
  918.   End If
  919. End Sub
  920.