home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l406 / 4.ddi / DYNASET.FR_ / DYNASET.bin (.txt)
Encoding:
Visual Basic Form  |  1992-10-21  |  23.9 KB  |  817 lines

  1. VERSION 2.00
  2. Begin Form fDynaset 
  3.    BackColor       =   &H00C0C0C0&
  4.    Height          =   3900
  5.    Icon            =   DYNASET.FRX:0000
  6.    Left            =   3615
  7.    LinkTopic       =   "Form1"
  8.    MDIChild        =   -1  'True
  9.    ScaleHeight     =   3480
  10.    ScaleMode       =   0  'User
  11.    ScaleWidth      =   5028
  12.    Tag             =   "Dynaset"
  13.    Top             =   2490
  14.    Width           =   5130
  15.    Begin PictureBox FieldHeader 
  16.       BackColor       =   &H00C0C0C0&
  17.       BorderStyle     =   0  'None
  18.       Height          =   241
  19.       Left            =   0
  20.       ScaleHeight     =   240
  21.       ScaleMode       =   0  'User
  22.       ScaleWidth      =   5028
  23.       TabIndex        =   18
  24.       Top             =   482
  25.       Width           =   5007
  26.       Begin Label FieldValueLabel 
  27.          BackColor       =   &H00C0C0C0&
  28.          Caption         =   " Value  (F4=Zoom)"
  29.          Height          =   252
  30.          Left            =   1674
  31.          TabIndex        =   20
  32.          Top             =   0
  33.          Width           =   2643
  34.       End
  35.       Begin Label FieldHdrLabel 
  36.          BackColor       =   &H00C0C0C0&
  37.          Caption         =   "Field Name:"
  38.          Height          =   252
  39.          Left            =   120
  40.          TabIndex        =   19
  41.          Top             =   0
  42.          Width           =   1208
  43.       End
  44.    End
  45.    Begin PictureBox ViewButtons 
  46.       Align           =   1  'Align Top
  47.       BackColor       =   &H00C0C0C0&
  48.       BorderStyle     =   0  'None
  49.       Height          =   480
  50.       Left            =   0
  51.       ScaleHeight     =   480
  52.       ScaleMode       =   0  'User
  53.       ScaleWidth      =   5012.991
  54.       TabIndex        =   0
  55.       Top             =   0
  56.       Width           =   5010
  57.       Begin CommandButton CloseButton 
  58.          Caption         =   "&Close"
  59.          Height          =   372
  60.          Left            =   4320
  61.          TabIndex        =   11
  62.          TabStop         =   0   'False
  63.          Top             =   50
  64.          Width           =   612
  65.       End
  66.       Begin CommandButton PropButton 
  67.          Caption         =   "&Prop"
  68.          Height          =   372
  69.          Left            =   3720
  70.          TabIndex        =   7
  71.          Top             =   50
  72.          Width           =   612
  73.       End
  74.       Begin CommandButton DelButton 
  75.          Caption         =   "&Del"
  76.          Height          =   372
  77.          Left            =   3120
  78.          TabIndex        =   6
  79.          Top             =   50
  80.          Width           =   612
  81.       End
  82.       Begin CommandButton EditButton 
  83.          Caption         =   "&Edit"
  84.          Height          =   372
  85.          Left            =   2520
  86.          TabIndex        =   5
  87.          Top             =   50
  88.          Width           =   612
  89.       End
  90.       Begin CommandButton AddButton 
  91.          Caption         =   "&Add"
  92.          Height          =   372
  93.          Left            =   1920
  94.          TabIndex        =   4
  95.          Top             =   50
  96.          Width           =   612
  97.       End
  98.       Begin CommandButton FindButton 
  99.          Caption         =   "F&ind"
  100.          Height          =   372
  101.          Left            =   1320
  102.          TabIndex        =   3
  103.          Top             =   50
  104.          Width           =   612
  105.       End
  106.       Begin CommandButton FirstButton 
  107.          Caption         =   "&First"
  108.          Height          =   372
  109.          Left            =   720
  110.          TabIndex        =   2
  111.          Top             =   50
  112.          Width           =   612
  113.       End
  114.       Begin CommandButton NextButton 
  115.          Caption         =   "&Next"
  116.          Height          =   372
  117.          Left            =   120
  118.          TabIndex        =   1
  119.          Top             =   50
  120.          Width           =   612
  121.       End
  122.    End
  123.    Begin PictureBox ChangeButtons 
  124.       BackColor       =   &H00C0C0C0&
  125.       BorderStyle     =   0  'None
  126.       Height          =   480
  127.       Left            =   0
  128.       ScaleHeight     =   480
  129.       ScaleMode       =   0  'User
  130.       ScaleWidth      =   5028
  131.       TabIndex        =   8
  132.       Top             =   0
  133.       Visible         =   0   'False
  134.       Width           =   5028
  135.       Begin CommandButton UpdateButton 
  136.          Caption         =   "&Update"
  137.          Height          =   372
  138.          Left            =   960
  139.          TabIndex        =   10
  140.          Top             =   48
  141.          Width           =   1212
  142.       End
  143.       Begin CommandButton CancelButton 
  144.          Cancel          =   -1  'True
  145.          Caption         =   "&Cancel"
  146.          Height          =   372
  147.          Left            =   2640
  148.          TabIndex        =   9
  149.          Top             =   48
  150.          Width           =   1212
  151.       End
  152.    End
  153.    Begin PictureBox StatBox 
  154.       Align           =   2  'Align Bottom
  155.       BackColor       =   &H00FFFFFF&
  156.       Height          =   225
  157.       Left            =   0
  158.       ScaleHeight     =   204
  159.       ScaleMode       =   0  'User
  160.       ScaleWidth      =   6292.909
  161.       TabIndex        =   16
  162.       Top             =   3270
  163.       Width           =   5010
  164.       Begin Label cStatusBar 
  165.          BackColor       =   &H00FFFFFF&
  166.          Height          =   252
  167.          Left            =   95
  168.          TabIndex        =   17
  169.          Top             =   0
  170.          Width           =   3827
  171.       End
  172.    End
  173.    Begin VScrollBar cScrollBar 
  174.       Height          =   2627
  175.       LargeChange     =   3000
  176.       Left            =   5022
  177.       SmallChange     =   300
  178.       TabIndex        =   15
  179.       Top             =   723
  180.       Visible         =   0   'False
  181.       Width           =   251
  182.    End
  183.    Begin PictureBox cFields 
  184.       BackColor       =   &H00C0C0C0&
  185.       BorderStyle     =   0  'None
  186.       Height          =   377
  187.       Left            =   120
  188.       ScaleHeight     =   372
  189.       ScaleMode       =   0  'User
  190.       ScaleWidth      =   4812
  191.       TabIndex        =   12
  192.       Top             =   723
  193.       Width           =   4798
  194.       Begin TextBox cFieldData 
  195.          BackColor       =   &H00FFFFFF&
  196.          Height          =   290
  197.          Index           =   0
  198.          Left            =   1556
  199.          TabIndex        =   13
  200.          Top             =   0
  201.          Visible         =   0   'False
  202.          Width           =   3244
  203.       End
  204.       Begin Label cFieldName 
  205.          BackColor       =   &H00C0C0C0&
  206.          ForeColor       =   &H00000000&
  207.          Height          =   254
  208.          Index           =   0
  209.          Left            =   0
  210.          TabIndex        =   14
  211.          Top             =   60
  212.          Visible         =   0   'False
  213.          Width           =   1568
  214.       End
  215.    End
  216. Option Explicit
  217. 'form variables
  218. Dim FDS As Dynaset            'current form's dynaset
  219. Dim FTblName As String        'form dynaset table name
  220. Dim FNotFound As Integer      'used by find function
  221. Dim FAtTop As Integer         'top flag
  222. Dim FEditFlag As Integer      'edit mode
  223. Dim FAddNewFlag As Integer    'add mode
  224. Dim FFldDataChanged As Integer
  225. Dim FFindForm As New fFind    'find form instance
  226. Dim FCurrRec As Integer       'record counter
  227. Dim FNumbRows As Long         'total rows in dynaset
  228. Dim FDynaString As String     'dynaset open string
  229. Sub AddButton_Click ()
  230.   On Error GoTo AddErr
  231.   'move to the end so you'll be on the
  232.   'record after the add is complete
  233. '  While FDS.EOF = False
  234. '    FDS.MoveNext
  235. '  Wend
  236.   'set the mode
  237.   FDS.AddNew
  238.   cStatusBar = "Add record"
  239.   FAddNewFlag = True
  240.   ChangeButtons.Visible = True
  241.   ViewButtons.Visible = False
  242.   ClearDataFields
  243.   cFieldData(0).SetFocus
  244.   GoTo AddEnd
  245. AddErr:
  246.   ShowError
  247.   Resume AddEnd
  248. AddEnd:
  249. End Sub
  250. Sub CancelButton_Click ()
  251.    On Error Resume Next
  252.    ChangeButtons.Visible = False
  253.    ViewButtons.Visible = True
  254.    FDS.Edit     'get last read data from server
  255.    DisplayCurrentRecord
  256.    FEditFlag = False
  257.    FAddNewFlag = False
  258. End Sub
  259. Sub cFieldData_Change (Index As Integer)
  260.   'just set the flag if data is changed
  261.   'it gets reset to false when a new record is displayed
  262.   FFldDataChanged = True
  263. End Sub
  264. Sub cFieldData_KeyDown (Index As Integer, KeyCode As Integer, Shift As Integer)
  265.   If KeyCode = &H73 Then   'F4
  266.     cFieldName_DblClick Index
  267.   ElseIf KeyCode = 34 And cScrollBar.Visible = True Then
  268.     'pagedown with > 10 fields
  269.     cScrollBar = cScrollBar - 3000
  270.   ElseIf KeyCode = 33 And cScrollBar.Visible = True Then
  271.     'pageup with > 10 fields
  272.     cScrollBar = cScrollBar + 3000
  273.   End If
  274. End Sub
  275. Sub cFieldData_KeyPress (Index As Integer, KeyAscii As Integer)
  276.   'only allow return when in edit of add mode
  277.   If FEditFlag = True Or FAddNewFlag = True Then
  278.     If FDS(Index).Type = FT_STRING And Len(cFieldData(Index)) > FDS(Index).Size Then
  279.       Beep
  280.       MsgBox "Field Length Exceeded!", 48
  281.       KeyAscii = 0
  282.       Exit Sub
  283.     End If
  284.     If KeyAscii = 13 Then
  285.       KeyAscii = 0
  286.       SendKeys "{Tab}"
  287.     End If
  288.   'throw away the keystrokes if not in add or edit mode
  289.   ElseIf FEditFlag = False And FAddNewFlag = False Then
  290.     KeyAscii = 0
  291.   End If
  292. End Sub
  293. Sub cFieldData_LostFocus (Index As Integer)
  294.   On Error GoTo FldDataErr
  295.   If FFldDataChanged = True Then
  296.     'store the data in the field
  297.     FDS(Index) = cFieldData(Index)
  298.   End If
  299.   GoTo FldDataEnd
  300. FldDataErr:
  301.   ShowError
  302.   Resume FldDataEnd
  303. FldDataEnd:
  304.   'reset for valid or error condition
  305.   FFldDataChanged = False
  306. End Sub
  307. Sub cFieldName_DblClick (Index As Integer)
  308.   On Error GoTo ZoomErr
  309.   If FDS(Index).Type = FT_STRING Or FDS(Index).Type = FT_MEMO Then
  310.      If FDS(Index).FieldSize() < GETCHUNK_CUTOFF Then
  311.        gstZoomData = cFieldData(Index)
  312.      Else
  313.        'add the rest of the field data with getchunk
  314.        MsgBar "Getting Memo Field Data", True
  315.        SetHourGlass Me
  316.        gstZoomData = cFieldData(Index) + StripNonAscii(FDS(Index).GetChunk(GETCHUNK_CUTOFF, MAX_MEMO_SIZE))
  317.        ResetMouse Me
  318.        MsgBar "", False
  319.      End If
  320.      fZoom.Caption = Mid(cFieldName(Index), 1, Len(cFieldName(Index)) - 1)
  321.      fZoom.Top = Top + 1200
  322.      fZoom.Left = Left + 250
  323.      If FAddNewFlag Or FEditFlag Then
  324.        fZoom.SaveButton.Visible = True
  325.        fZoom.CloseButton.Visible = True
  326.      Else
  327.        fZoom.CloseZoomButton.Visible = True
  328.      End If
  329.      fZoom.Show MODAL
  330.      If FAddNewFlag Or FEditFlag Then
  331.        If FDS(Index).Type = FT_STRING And Len(gstZoomData) > FDS(Index).Size Then
  332.          Beep
  333.          MsgBox "Field Length Exceeded, Data Truncated!", 48
  334.          cFieldData(Index) = Mid(gstZoomData, 1, FDS(Index).Size)
  335.        Else
  336.          cFieldData(Index) = gstZoomData
  337.        End If
  338.        FDS(Index) = cFieldData(Index)
  339.        FFldDataChanged = False
  340.      End If
  341.   End If
  342.   GoTo ZoomEnd
  343. ZoomErr:
  344.   ShowError
  345.   Resume ZoomEnd
  346. ZoomEnd:
  347. End Sub
  348. Sub ClearDataFields ()
  349.   Dim i As Integer
  350.   'clear out the fields on the main form
  351.   For i = 0 To FDS.Fields.Count - 1
  352.     cFieldData(i) = ""
  353.   Next
  354. End Sub
  355. Sub CloseButton_Click ()
  356.   Unload Me
  357. End Sub
  358. Sub cScrollBar_Change ()
  359.   Dim t As Integer
  360.   t = cScrollBar
  361.   If (t - 720) Mod 300 = 0 Then
  362.     cFields.Top = t
  363.   Else
  364.     cFields.Top = ((t - 720) \ 300) * 300 + 720
  365.   End If
  366. End Sub
  367. Sub DelButton_Click ()
  368.   On Error GoTo DelRecErr
  369.   If MsgBox("Delete Current Record?", MSGBOX_TYPE) = YES Then
  370.     FDS.Delete
  371.     If gfTransPending Then gfDBChanged = True
  372.     If FDS.EOF = False Then
  373.       FDS.MoveNext
  374.     End If
  375.     FNumbRows = FNumbRows - 1
  376.     DisplayCurrentRecord
  377.   End If
  378.   GoTo DelRecEnd
  379. DelRecErr:
  380.   ShowError
  381.   Resume DelRecEnd
  382. DelRecEnd:
  383. End Sub
  384. Sub DisplayCurrentRecord ()
  385.    Dim i As Integer
  386.    Dim cst As String    'current status bar
  387.    On Error GoTo DCRErr
  388.    SetHourGlass Me
  389.    cst = "View Records  "
  390.    'check EOF flag so we know if we
  391.    'are sitting on a valid record
  392.    If FAddNewFlag = True Then
  393.      cst = cst + CStr(FCurrRec) + "/" + CStr(FNumbRows)
  394.    Else
  395.      If FDS.EOF <> False Then  '= True Then
  396.        cst = cst + "(EOF)/" + CStr(FNumbRows)
  397.        ClearDataFields
  398.      Else
  399.        cst = cst + CStr(FCurrRec) + "/" + CStr(FNumbRows)
  400.        'place the data in the form fields
  401.        For i = 0 To FDS.Fields.Count - 1
  402.          If FDS(i).Type = FT_MEMO Then
  403.            If FDS(i).FieldSize() < GETCHUNK_CUTOFF Then
  404.              cFieldData(i) = StripNonAscii(vFieldVal(FDS(i)))
  405.            Else
  406.              cFieldData(i) = StripNonAscii(vFieldVal(FDS(i).GetChunk(0, GETCHUNK_CUTOFF)))
  407.            End If
  408.          ElseIf FDS(i).Type = FT_STRING Then
  409.            cFieldData(i) = StripNonAscii(vFieldVal(FDS(i)))
  410.          Else
  411.            cFieldData(i) = vFieldVal(FDS(i))
  412.          End If
  413.        Next
  414.      End If
  415.    End If
  416.    If gfUpdatable = False Then cst = cst + "  [Not Updatable]"
  417.    cStatusBar = cst
  418.    'set the flag
  419.    FFldDataChanged = False
  420.    GoTo DCREnd
  421. DCRErr:
  422.   ShowError
  423.   Resume DCREnd
  424. DCREnd:
  425.    ResetMouse Me
  426. End Sub
  427. Sub EditButton_Click ()
  428.    On Error GoTo EditErr
  429.    FDS.Edit
  430.    cStatusBar = "Edit record"
  431.    FEditFlag = True
  432.    cFieldData(0).SetFocus
  433.    ChangeButtons.Visible = True
  434.    ViewButtons.Visible = False
  435.    GoTo EditEnd
  436. EditErr:
  437.   ShowError
  438.   Resume EditEnd
  439. EditEnd:
  440. End Sub
  441. Sub FindButton_Click ()
  442.   Dim i As Integer
  443.   If CheckTransPending("'Find' Not Available during a Transaction") = True Then Exit Sub
  444.   On Error GoTo FindErr
  445.   'load the column names into the find form
  446.   If FFindForm.cFieldList.ListCount = 0 Then
  447.     For i = 0 To FDS.Fields.Count - 1
  448.       FFindForm.cFieldList.AddItem Mid(cFieldName(i), 1, Len(cFieldName(i)) - 1)
  449.     Next
  450.   End If
  451. FindStart:
  452.   'reset the flags
  453.   gfFindFailed = False
  454.   gfFromTableView = False
  455.   FNotFound = False
  456.   MsgBar "Enter Search Parameters", False
  457.   FFindForm.Show MODAL
  458.   MsgBar "Searching for New Record", True
  459.   If gfFindFailed = True Then   'find cancelled
  460.     GoTo AfterWhile
  461.   End If
  462.   SetHourGlass Me
  463.   'reopen the dynaset if not at the top
  464.    If FAtTop = False Then
  465.      FDS.Close
  466.      Set FDS = gCurrentDB.CreateDynaset(FDS.Name)
  467.      FCurrRec = 1
  468.    End If
  469.    i = FFindForm.cFieldList.ListIndex
  470.    'search for the record
  471.    While FDS.EOF = False
  472.      If FDS(i).Type = FT_STRING Then
  473.        If gfFindMatch = False Then
  474.          Select Case gstFindOp
  475.            Case "="
  476.              If UCase(FDS(i)) = UCase(gstFindExpr) Then GoTo AfterWhile
  477.            Case "<>"
  478.              If UCase(FDS(i)) <> UCase(gstFindExpr) Then GoTo AfterWhile
  479.            Case ">="
  480.              If UCase(FDS(i)) >= UCase(gstFindExpr) Then GoTo AfterWhile
  481.            Case "<="
  482.              If UCase(FDS(i)) <= UCase(gstFindExpr) Then GoTo AfterWhile
  483.            Case ">"
  484.              If UCase(FDS(i)) > UCase(gstFindExpr) Then GoTo AfterWhile
  485.            Case "<"
  486.              If UCase(FDS(i)) < UCase(gstFindExpr) Then GoTo AfterWhile
  487.            Case "Like"
  488.              If UCase(FDS(i)) Like UCase(gstFindExpr) Then GoTo AfterWhile
  489.          End Select
  490.        Else
  491.          Select Case gstFindOp
  492.            Case "="
  493.              If FDS(i) = gstFindExpr Then GoTo AfterWhile
  494.            Case "<>"
  495.              If FDS(i) <> gstFindExpr Then GoTo AfterWhile
  496.            Case ">="
  497.              If FDS(i) >= gstFindExpr Then GoTo AfterWhile
  498.            Case "<="
  499.              If FDS(i) <= gstFindExpr Then GoTo AfterWhile
  500.            Case ">"
  501.              If FDS(i) > gstFindExpr Then GoTo AfterWhile
  502.            Case "<"
  503.              If FDS(i) < gstFindExpr Then GoTo AfterWhile
  504.            Case "Like"
  505.              If FDS(i) Like gstFindExpr Then GoTo AfterWhile
  506.          End Select
  507.        End If
  508.      Else
  509.        Select Case gstFindOp
  510.          Case "="
  511.            If FDS(i) = Val(gstFindExpr) Then GoTo AfterWhile
  512.          Case "<>"
  513.            If FDS(i) <> Val(gstFindExpr) Then GoTo AfterWhile
  514.          Case ">="
  515.            If FDS(i) >= Val(gstFindExpr) Then GoTo AfterWhile
  516.          Case "<="
  517.            If FDS(i) <= Val(gstFindExpr) Then GoTo AfterWhile
  518.          Case ">"
  519.            If FDS(i) > Val(gstFindExpr) Then GoTo AfterWhile
  520.          Case "<"
  521.            If FDS(i) < Val(gstFindExpr) Then GoTo AfterWhile
  522.        End Select
  523.      End If
  524.      FDS.MoveNext
  525.      FCurrRec = FCurrRec + 1
  526.    Wend
  527.    FNotFound = True       'didn't find it
  528. AfterWhile:
  529.    ResetMouse Me
  530.    FAtTop = False
  531.    If gfFindFailed = True Then   'go back to top
  532.      FDS.Close
  533.      Set FDS = gCurrentDB.CreateDynaset(FDS.Name)
  534.      FAtTop = True
  535.      FCurrRec = 1
  536.    ElseIf FNotFound Then
  537.      Beep
  538.      MsgBox "Record Not Found", 48
  539.      GoTo FindStart
  540.    End If
  541.    DisplayCurrentRecord
  542.    GoTo FindEnd
  543. FindErr:
  544.    ResetMouse Me
  545.    If Err <> EOF_ERR Then
  546.      ShowError
  547.      Resume FindEnd
  548.    Else
  549.      FNotFound = True
  550.      Resume Next
  551.    End If
  552. FindEnd:
  553.    MsgBar "", False
  554. End Sub
  555. Sub FirstButton_Click ()
  556.    On Error GoTo GoFirstError
  557.    If CheckTransPending("'First' Not Available during a Transaction") = True Then Exit Sub
  558.    MsgBar "Going to First Record", True
  559.    SetHourGlass Me
  560.    FDS.Close
  561.    Set FDS = gCurrentDB.CreateDynaset(FDS.Name)
  562.    FNumbRows = GetNumbRecs(FDS, FDynaString)
  563.    'show the first record
  564.    FCurrRec = 1
  565.    DisplayCurrentRecord
  566.    FAtTop = True
  567.    GoTo GoFirstEnd
  568. GoFirstError:
  569.    ShowError
  570.    Resume GoFirstEnd
  571. GoFirstEnd:
  572.    ResetMouse Me
  573.    MsgBar "", False
  574. End Sub
  575. Sub Form_Load ()
  576.    Dim t As TableDef       'local table structure
  577.    Dim sp As Integer       'starting point of table name
  578.    Dim ep As Integer       'ending point of table name
  579.    Dim ds As String        'temp dynaset name string
  580.    Dim wh As String        'where clause
  581.    Dim ft As Integer
  582.    Dim i As Integer, j As Integer
  583.    Dim fn As String        'field name
  584.    Dim l As Long
  585.    On Error GoTo DynasetErr
  586.    SetHourGlass Me
  587.    MsgBar "Opening Dynaset", True
  588.    'assign the temp string with the select statement
  589.    'if it is not empty, otherwise, use the table list name
  590.    If gfFromSQL = True Then
  591.      If gstDynaString = "" Then
  592.        ds = fSQL.cSQLStatement
  593.      Else
  594.        ds = gstDynaString
  595.      End If
  596.    Else
  597.      ds = fTables.cTableList
  598.    End If
  599.    'attemp to open the dynaset
  600.    Set FDS = gCurrentDB.CreateDynaset(ds)
  601.    'parse off table name to store in global gstTblName
  602.    wh = ""
  603.    sp = InStr(1, UCase(ds), "FROM")
  604.    If sp > 0 Then
  605.      'must be a "select from" statement
  606.      sp = sp + 5
  607.      For ep = sp To Len(ds)
  608.        'search for a space or the end of ds
  609.        If Mid$(ds, ep, 1) = " " Then
  610.          'get where clause if there is one
  611.          wh = Mid$(ds, sp, Len(ds) - sp + 1)
  612.          Exit For
  613.        End If
  614.      Next
  615.      FTblName = UCase(Mid$(ds, sp, ep - sp))
  616.      If wh = "" Then wh = FTblName
  617.    Else
  618.      'must be a table name only
  619.      FTblName = UCase(ds)
  620.      wh = FTblName
  621.    End If
  622.    FDynaString = wh
  623.    'show the first record
  624.    FNumbRows = GetNumbRecs(FDS, wh)          'query numb of recs
  625.    'load the controls on the dynaset form
  626.    cFieldName(0).Visible = True
  627.    cFieldData(0).Visible = True
  628.    ft = FDS(0).Type
  629.    cFieldData(0).Width = GetFieldWidth(ft)
  630.    cFieldData(0).TabIndex = 0
  631.    For i = 1 To FDS.Fields.Count - 1
  632.      cFields.Height = cFields.Height + 300
  633.      Load cFieldName(i)
  634.      cFieldName(i).Top = cFieldName(i - 1).Top + 300
  635.      cFieldName(i).Visible = True
  636.      Load cFieldData(i)
  637.      cFieldData(i).Top = cFieldData(i - 1).Top + 300
  638.      cFieldData(i).Visible = True
  639.      ft = FDS(i).Type
  640.      cFieldData(i).Width = GetFieldWidth(ft)
  641.      cFieldData(i).TabIndex = i
  642.    Next
  643.    'resize main window
  644.    If i <= 10 Then
  645.      Height = i * 300 + 1400
  646.    Else
  647.      Height = 4368
  648.      Width = Width + 260
  649.      cScrollBar.Visible = True
  650.      cScrollBar.Min = 720
  651.      cScrollBar.Max = 720 - (i * 300) + 3000
  652.    End If
  653.    'display the field names
  654.    If gfFromSQL = False Or InStr(1, ds, "*") > 1 Then
  655.      For i = 0 To FDS.Fields.Count - 1
  656.        cFieldName(i) = UCase(FDS(i).Name) + ":"
  657.      Next
  658.    Else
  659.      'parse off field names
  660.      j = 8
  661.      For i = 0 To FDS.Fields.Count - 1
  662.        fn = ""
  663.        While Mid(ds, j, 1) <> "," And Mid(ds, j, 1) <> " "
  664.          fn = fn + Mid(ds, j, 1)
  665.          j = j + 1
  666.        Wend
  667.        While Mid(ds, j, 1) = "," Or Mid(ds, j, 1) = " "
  668.          j = j + 1
  669.        Wend
  670.        cFieldName(i) = UCase(fn) + ":"
  671.      Next
  672.    End If
  673.    FCurrRec = 1
  674.    DisplayCurrentRecord      'display field values
  675.    FAtTop = True
  676.    Caption = "Dynaset: " + FTblName
  677.    Width = 5430
  678.    Left = 1000
  679.    Top = 1000
  680.    GoTo OkayEnd
  681. DynasetErr:
  682.    ShowError
  683.    Unload Me
  684.    Exit Sub
  685.    Resume OkayEnd
  686. OkayEnd:
  687.    ResetMouse Me
  688.    MsgBar "", False
  689. End Sub
  690. Sub Form_Resize ()
  691.   Dim h As Integer, i As Integer
  692.   Dim totw As Integer
  693.   If WindowState <> 1 Then   'not minimized
  694.     MsgBar "Resizing Form", True
  695.     'make sure the form is lined up on a field
  696.     h = Height
  697.     If (h - 1368) Mod 300 <> 0 Then
  698.       Height = ((h - 1368) \ 300) * 300 + 1368
  699.     End If
  700.     'resize the status bar
  701.     StatBox.Top = Height - 650
  702.     'resize the scrollbar
  703.     cScrollBar.Height = StatBox.Top - (ViewButtons.Top - FieldHeader.Height) - 980
  704.     cScrollBar.Left = Width - 360
  705.     If FDS.Fields.Count > 10 Then
  706.       cFields.Width = Width - 260
  707.       totw = cScrollBar.Left - 20
  708.     Else
  709.       cFields.Width = Width - 20
  710.       totw = Width - 50
  711.     End If
  712.     FieldHeader.Width = Width - 20
  713.     'widen the fields if possible
  714.     For i = 0 To FDS.Fields.Count - 1
  715.       cFieldName(i).Width = .3 * totw
  716.       cFieldData(i).Left = cFieldName(i).Width + 20
  717.       If FDS(i).Type = FT_STRING Or FDS(i).Type = FT_MEMO Then
  718.         cFieldData(i).Width = .7 * totw - 250
  719.       End If
  720.     Next
  721.     FieldValueLabel.Left = cFieldData(0).Left
  722.   End If
  723.   MsgBar "", False
  724. End Sub
  725. Sub Form_Unload (Cancel As Integer)
  726.   On Error Resume Next
  727.   Unload FFindForm   'get rid of attached find form
  728.   FDS.Close          'close the form dynaset
  729.   MsgBar "", False
  730. End Sub
  731. Sub NextButton_Click ()
  732.    On Error GoTo GoNextError
  733.    If FDS.EOF = True Then
  734.      MsgBox "EOF Set, Going to First Row.", 48
  735.      GoTo EmptyDynaOnNext
  736.    End If
  737.    FDS.MoveNext
  738.    'show the current record
  739.    FCurrRec = FCurrRec + 1   'bump the record counter
  740.    DisplayCurrentRecord
  741.    FAtTop = False
  742.    GoTo GoNextEnd
  743. GoNextError:
  744.    ShowError
  745.    Resume GoNextEnd
  746. EmptyDynaOnNext:
  747.   Call FirstButton_Click
  748. GoNextEnd:
  749. End Sub
  750. Sub PropButton_Click ()
  751.    Dim f As New fDataBox
  752.    Dim s As String
  753.    On Error GoTo DynPropErr
  754.    f.cData.AddItem "Name = " + FDS.Name
  755.    f.Caption = "Dynaset Properties"
  756.    f.Top = Top + 700
  757.    f.Left = Left + 100
  758.    'set the value of the EOF flag
  759.    If FDS.EOF Then
  760.      s = TRUE_ST
  761.    Else
  762.      s = FALSE_ST
  763.    End If
  764.    f.cData.AddItem "EOF Flag = " + s
  765.    'set the value of the updatable flag
  766.    If FDS.Updatable Then
  767.      s = TRUE_ST
  768.    Else
  769.      s = FALSE_ST
  770.    End If
  771.    f.cData.AddItem "Updatable = " + s
  772.    'set the value of the transactions flag
  773.    If FDS.Transactions Then
  774.      s = TRUE_ST
  775.    Else
  776.      s = FALSE_ST
  777.    End If
  778.    f.cData.AddItem "Transactions = " + s
  779.    f.Show
  780.   GoTo DynPropEnd
  781. DynPropErr:
  782.   ShowError
  783.   Resume DynPropEnd
  784. DynPropEnd:
  785. End Sub
  786. Sub UpdateButton_Click ()
  787.   On Error GoTo UpdateErr
  788.   FDS.Update
  789.   If gfTransPending Then gfDBChanged = True
  790.   If FAddNewFlag = True Then
  791.     If FNumbRows = 0 Then
  792.       'special case for empty dynaset
  793.       'reopens the dynaset so we are on the
  794.       'newly added record
  795.       GoTo EmptyDyn
  796.     End If
  797.     FNumbRows = FNumbRows + 1
  798.     FCurrRec = FNumbRows
  799.   End If
  800.   DisplayCurrentRecord
  801.   ChangeButtons.Visible = False
  802.   ViewButtons.Visible = True
  803.   FEditFlag = False
  804.   FAddNewFlag = False
  805.   GoTo UpdateEnd
  806. UpdateErr:
  807.   ShowError
  808.   Resume UpdateEnd
  809. EmptyDyn:
  810.   ChangeButtons.Visible = False
  811.   ViewButtons.Visible = True
  812.   FEditFlag = False
  813.   FAddNewFlag = False
  814.   Call FirstButton_Click
  815. UpdateEnd:
  816. End Sub
  817.