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

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