home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / forms / frmwiz / fieldfrm.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-01-15  |  11.2 KB  |  346 lines

  1. VERSION 2.00
  2. Begin Form FieldFrm 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Form Wizard - Field Selection"
  6.    ClientHeight    =   5115
  7.    ClientLeft      =   1095
  8.    ClientTop       =   1260
  9.    ClientWidth     =   7845
  10.    ControlBox      =   0   'False
  11.    Height          =   5520
  12.    HelpContextID   =   26
  13.    Icon            =   FIELDFRM.FRX:0000
  14.    Left            =   1035
  15.    LinkTopic       =   "Form2"
  16.    ScaleHeight     =   5115
  17.    ScaleWidth      =   7845
  18.    Top             =   915
  19.    Width           =   7965
  20.    Begin SSCommand BtnHelp 
  21.       Caption         =   "&Help"
  22.       Font3D          =   2  'Raised w/heavy shading
  23.       Height          =   615
  24.       Left            =   4860
  25.       Picture         =   FIELDFRM.FRX:0302
  26.       TabIndex        =   11
  27.       Top             =   4020
  28.       Width           =   915
  29.    End
  30.    Begin SSPanel cMsg 
  31.       Align           =   2  'Align Bottom
  32.       Alignment       =   1  'Left Justify - MIDDLE
  33.       BevelInner      =   1  'Inset
  34.       BorderWidth     =   2
  35.       Height          =   375
  36.       Left            =   0
  37.       TabIndex        =   10
  38.       Top             =   4740
  39.       Width           =   7845
  40.    End
  41.    Begin SSCommand BtnFinish 
  42.       AutoSize        =   2  'Adjust Button Size To Picture
  43.       Caption         =   "&Finish"
  44.       Enabled         =   0   'False
  45.       Font3D          =   2  'Raised w/heavy shading
  46.       Height          =   615
  47.       Left            =   3960
  48.       Picture         =   FIELDFRM.FRX:0604
  49.       TabIndex        =   9
  50.       Top             =   4020
  51.       Width           =   915
  52.    End
  53.    Begin SSCommand BtnCancel 
  54.       AutoSize        =   2  'Adjust Button Size To Picture
  55.       Caption         =   "&Cancel"
  56.       Font3D          =   2  'Raised w/heavy shading
  57.       Height          =   615
  58.       Left            =   3060
  59.       Picture         =   FIELDFRM.FRX:0906
  60.       TabIndex        =   6
  61.       Tag             =   "Cancel building the form"
  62.       Top             =   4020
  63.       Width           =   915
  64.    End
  65.    Begin SSCommand BtnNext 
  66.       AutoSize        =   2  'Adjust Button Size To Picture
  67.       Caption         =   "&Next"
  68.       Font3D          =   2  'Raised w/heavy shading
  69.       Height          =   615
  70.       Left            =   2160
  71.       Picture         =   FIELDFRM.FRX:0C08
  72.       TabIndex        =   5
  73.       Tag             =   "Proceed to the next step"
  74.       Top             =   4020
  75.       Width           =   915
  76.    End
  77.    Begin SSCommand BtnPrev 
  78.       AutoSize        =   2  'Adjust Button Size To Picture
  79.       Caption         =   "&Previous"
  80.       Font3D          =   2  'Raised w/heavy shading
  81.       Height          =   615
  82.       Left            =   1260
  83.       Picture         =   FIELDFRM.FRX:0F0A
  84.       TabIndex        =   4
  85.       Tag             =   "Return to the previous step"
  86.       Top             =   4020
  87.       Width           =   915
  88.    End
  89.    Begin SSFrame FramFldsOnForm 
  90.       Alignment       =   2  'Center
  91.       Caption         =   "Fields On Form"
  92.       ForeColor       =   &H00FF0000&
  93.       Height          =   3675
  94.       Left            =   3900
  95.       TabIndex        =   8
  96.       Top             =   240
  97.       Width           =   3795
  98.       Begin Grid GrdFields 
  99.          Cols            =   4
  100.          FixedRows       =   0
  101.          Height          =   3315
  102.          Left            =   120
  103.          Rows            =   1
  104.          TabIndex        =   2
  105.          Tag             =   "Select one or more fields, right click to change attributes"
  106.          Top             =   240
  107.          Width           =   3555
  108.       End
  109.    End
  110.    Begin SSFrame Frame3D1 
  111.       Alignment       =   2  'Center
  112.       Caption         =   "Select Fields For Form"
  113.       ForeColor       =   &H00FF0000&
  114.       Height          =   3735
  115.       Left            =   120
  116.       TabIndex        =   7
  117.       Top             =   180
  118.       Width           =   2595
  119.       Begin ListBox LstFields 
  120.          BackColor       =   &H00C0C0C0&
  121.          Height          =   3345
  122.          Left            =   120
  123.          MultiSelect     =   2  'Extended
  124.          TabIndex        =   0
  125.          Tag             =   "Select one or more fields to add to the form"
  126.          Top             =   300
  127.          Width           =   2355
  128.       End
  129.    End
  130.    Begin SSCommand BtnRemove 
  131.       AutoSize        =   2  'Adjust Button Size To Picture
  132.       Caption         =   "&Remove"
  133.       Font3D          =   2  'Raised w/heavy shading
  134.       Height          =   555
  135.       Left            =   2820
  136.       Picture         =   FIELDFRM.FRX:120C
  137.       TabIndex        =   3
  138.       Tag             =   "Remove selected field(s) from the form"
  139.       Top             =   1200
  140.       Width           =   975
  141.    End
  142.    Begin SSCommand BtnAdd 
  143.       AutoSize        =   2  'Adjust Button Size To Picture
  144.       Caption         =   "&Add"
  145.       Font3D          =   2  'Raised w/heavy shading
  146.       Height          =   555
  147.       Left            =   2820
  148.       Picture         =   FIELDFRM.FRX:150E
  149.       TabIndex        =   1
  150.       Tag             =   "Add selected field(s) to the form"
  151.       Top             =   600
  152.       Width           =   975
  153.    End
  154. Option Explicit
  155. Dim maxwidth(3) As Long
  156. Sub BtnAdd_Click ()
  157.     Dim i As Integer, fld As String
  158.     ' Add selected feilds to grid
  159.     For i = 0 To LstFields.ListCount - 1
  160.         If LstFields.Selected(i) Then
  161.             fld = LstFields.List(i)
  162.             GrdFields.AddItem fld & Chr$(9) & fld & Chr$(9) & "No" & Chr$(9) & Str$(aiFldSize(i))
  163.             If TextWidth(fld) + 150 > maxwidth(0) Then
  164.                 maxwidth(0) = TextWidth(fld) + 150
  165.                 GrdFields.ColWidth(0) = maxwidth(0)
  166.             End If
  167.             If TextWidth(fld) + 150 > maxwidth(1) Then
  168.                 maxwidth(1) = TextWidth(fld) + 150
  169.                 GrdFields.ColWidth(1) = maxwidth(1)
  170.             End If
  171.         End If
  172.     Next i
  173.     If GrdFields.Rows > 1 Then GrdFields.FixedRows = 1
  174. End Sub
  175. Sub BtnAdd_GotFocus ()
  176.     cMsg.Caption = BtnAdd.Tag
  177. End Sub
  178. Sub BtnCancel_Click ()
  179.     EndItNow
  180. End Sub
  181. Sub BtnCancel_GotFocus ()
  182.     cMsg.Caption = BtnCancel.Tag
  183. End Sub
  184. Sub BtnHelp_Click ()
  185.     SendKeys "{F1}"
  186. End Sub
  187. Sub BtnNext_Click ()
  188.     Dim contanyway As Integer
  189.     Dim msg As String
  190.     If GrdFields.Rows = 1 Then
  191.         Beep
  192.         msg = "You haven't specified any fields for the form!  Do you want to continue anyway?"
  193.         contanyway = MsgBox(msg, MB_ICONQUESTION + MB_YESNO, "Field Selection")
  194.         If contanyway = IDNO Then
  195.             Exit Sub
  196.         End If
  197.     End If
  198.     GenForm.Show MODELESS
  199.     FieldFrm.Hide
  200. End Sub
  201. Sub BtnNext_GotFocus ()
  202.     cMsg.Caption = BtnNext.Tag
  203. End Sub
  204. Sub BtnPrev_Click ()
  205.     DataSpec.Show MODELESS
  206.     FieldFrm.Hide
  207. End Sub
  208. Sub BtnPrev_GotFocus ()
  209.     cMsg.Caption = BtnPrev.Tag
  210. End Sub
  211. Sub BtnRemove_Click ()
  212.     On Error GoTo removeerr
  213.     Dim i As Integer, i2 As Integer
  214.     ' Remove any selected rows except the last one
  215.     For i = GrdFields.Rows - 2 To 0 Step -1
  216.         GrdFields.Row = i
  217.         GrdFields.Col = 1
  218.         If GrdFields.CellSelected Then
  219.             GrdFields.RemoveItem i
  220.         End If
  221.     Next i
  222.     ' Check if last row is deleted and handle special to prevent error
  223.     ' caused by selection defaulting to the entire table when the last
  224.     ' row is removed
  225.     i = GrdFields.Rows - 1
  226.     GrdFields.Row = i
  227.     GrdFields.Col = 1
  228.     If GrdFields.CellSelected Then
  229.         GrdFields.FixedRows = 0
  230.         GrdFields.RemoveItem i
  231.     End If
  232.     GrdFields.Refresh
  233.     If GrdFields.Rows > 1 Then GrdFields.FixedRows = 1
  234.     Exit Sub
  235. removeerr:
  236.     erraction = RB_ErrorHandler("FieldFrm", "BtnRemove_Click")
  237.     Select Case erraction
  238.     Case 1
  239.         Resume 0      ' Retry option selected
  240.     Case 2
  241.         Resume Next   ' Ignore option selected
  242.     End Select
  243. End Sub
  244. Sub BtnRemove_GotFocus ()
  245.     cMsg.Caption = BtnRemove.Tag
  246. End Sub
  247. Sub Form_Activate ()
  248.     Dim ds As dynaset, ssfields As snapshot
  249.     Dim iNumFlds As Integer
  250.     On Error GoTo formacterr
  251.     ' Load list of fields in record source
  252.     If NewRecordSource Then
  253.         Set ds = db.CreateDynaset(DataSpec.LstRecSrce.Text)
  254.         Set ssfields = ds.ListFields()
  255.         ds.Close
  256.         LstFields.Clear
  257.         ReDim aiFldSize(1)
  258.         iNumFlds = -1
  259.         Do While Not ssfields.EOF
  260.             LstFields.AddItem ssfields!Name
  261.             iNumFlds = iNumFlds + 1
  262.             ReDim Preserve aiFldSize(iNumFlds)
  263.             aiFldSize(iNumFlds) = ssfields!Size
  264.             ssfields.MoveNext
  265.         Loop
  266.         ssfields.Close
  267.         NewRecordSource = False
  268.         ' Clear the grid of fields
  269.         GrdFields.Rows = 1
  270.     End If
  271.     Exit Sub
  272. formacterr:
  273.     erraction = RB_ErrorHandler("FieldFrm", "Form_Activate")
  274.     Select Case erraction
  275.     Case 1
  276.         Resume 0      ' Retry option selected
  277.     Case 2
  278.         Resume Next   ' Ignore option selected
  279.     End Select
  280. End Sub
  281. Sub Form_Load ()
  282.     On Error GoTo loaderr
  283.     ' Set up grid headings
  284.     GrdFields.Row = 0
  285.     GrdFields.Col = 0
  286.     GrdFields.Text = "Field"
  287.     GrdFields.ColWidth(0) = TextWidth(" Field ")
  288.     maxwidth(0) = GrdFields.ColWidth(0)
  289.     GrdFields.Col = 1
  290.     GrdFields.Text = "Label"
  291.     GrdFields.ColWidth(1) = TextWidth(" Label ")
  292.     maxwidth(1) = GrdFields.ColWidth(1)
  293.     GrdFields.Col = 2
  294.     GrdFields.Text = "Same" & Chr$(13) & "Line"
  295.     GrdFields.ColWidth(2) = TextWidth(" Same ")
  296.     maxwidth(2) = GrdFields.ColWidth(2)
  297.     GrdFields.Col = 3
  298.     GrdFields.Text = "Size"
  299.     GrdFields.ColWidth(3) = TextWidth(" Size ")
  300.     GrdFields.RowHeight(0) = 2 * TextHeight("Same")
  301.     Exit Sub
  302. loaderr:
  303.     erraction = RB_ErrorHandler("FieldFrm", "Form_Load")
  304.     Select Case erraction
  305.     Case 1
  306.         Resume 0      ' Retry option selected
  307.     Case 2
  308.         Resume Next   ' Ignore option selected
  309.     End Select
  310. End Sub
  311. Sub Form_Resize ()
  312.     If FieldFrm.WindowState <> 1 Then
  313.         FramFldsOnForm.Width = FieldFrm.Width - FramFldsOnForm.Left - 250
  314.         GrdFields.Width = FramFldsOnForm.Width - GrdFields.Left - 150
  315.     End If
  316. End Sub
  317. Sub GrdFields_GotFocus ()
  318.     cMsg.Caption = GrdFields.Tag
  319. End Sub
  320. Sub GrdFields_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  321.     Dim i As Integer, istart As Integer, iend As Integer
  322.     If Button = RIGHT_BUTTON Then
  323.         istart = GrdFields.SelStartRow
  324.         If istart = 0 Then istart = 1
  325.         iend = GrdFields.SelEndRow
  326.         For i = istart To iend
  327.             GrdFields.Row = i
  328.             GrdFields.Col = 0
  329.             ChngFld.LblField.Caption = GrdFields.Text
  330.             GrdFields.Col = 1
  331.             ChngFld.TxtLabel = GrdFields.Text
  332.             GrdFields.Col = 2
  333.             If GrdFields.Text = "Yes" Then
  334.                 ChngFld.ChkSameLine.Value = True
  335.             Else
  336.                 ChngFld.ChkSameLine.Value = False
  337.             End If
  338.             ChngFld.LblRow.Caption = Str$(i)
  339.             ChngFld.Show MODAL
  340.         Next i
  341.     End If
  342. End Sub
  343. Sub LstFields_GotFocus ()
  344.     cMsg.Caption = LstFields.Tag
  345. End Sub
  346.