home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / code / database / browa / brwdemo.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-02-27  |  5.9 KB  |  189 lines

  1. VERSION 2.00
  2. Begin Form BrwDemo 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Product Groups"
  5.    ClientHeight    =   4980
  6.    ClientLeft      =   870
  7.    ClientTop       =   1290
  8.    ClientWidth     =   5280
  9.    Height          =   5505
  10.    Left            =   810
  11.    MaxButton       =   0   'False
  12.    ScaleHeight     =   4980
  13.    ScaleWidth      =   5280
  14.    Top             =   825
  15.    Width           =   5400
  16.    Begin CommandButton comProducts 
  17.       Caption         =   "&Products"
  18.       Height          =   372
  19.       Left            =   3960
  20.       TabIndex        =   9
  21.       Top             =   120
  22.       Width           =   1212
  23.    End
  24.    Begin TextBox txtEdt 
  25.       DataField       =   "DESCR"
  26.       DataSource      =   "dtaPrdGroup"
  27.       Height          =   288
  28.       Index           =   3
  29.       Left            =   1320
  30.       TabIndex        =   8
  31.       Top             =   1200
  32.       Width           =   3852
  33.    End
  34.    Begin TextBox txtEdt 
  35.       DataField       =   "TYPE"
  36.       DataSource      =   "dtaPrdGroup"
  37.       Enabled         =   0   'False
  38.       Height          =   288
  39.       Index           =   2
  40.       Left            =   1320
  41.       TabIndex        =   6
  42.       Top             =   840
  43.       Width           =   1092
  44.    End
  45.    Begin TextBox txtEdt 
  46.       DataField       =   "CODE"
  47.       DataSource      =   "dtaPrdGroup"
  48.       Enabled         =   0   'False
  49.       Height          =   288
  50.       Index           =   1
  51.       Left            =   1320
  52.       TabIndex        =   4
  53.       Top             =   480
  54.       Width           =   1092
  55.    End
  56.    Begin TextBox txtEdt 
  57.       DataField       =   "GROUP"
  58.       DataSource      =   "dtaPrdGroup"
  59.       Enabled         =   0   'False
  60.       Height          =   288
  61.       Index           =   0
  62.       Left            =   1320
  63.       TabIndex        =   2
  64.       Top             =   120
  65.       Width           =   1092
  66.    End
  67.    Begin TBrowse Brw 
  68.       BorderStyle     =   0  'None
  69.       DataSource      =   "dtaPrdGroup"
  70.       Height          =   2892
  71.       Left            =   120
  72.       TabIndex        =   0
  73.       Top             =   1560
  74.       Width           =   5052
  75.    End
  76.    Begin Data dtaPrdGroup 
  77.       Caption         =   "Product Group Data Control"
  78.       Connect         =   ""
  79.       DatabaseName    =   "C:\VB\CDK\BRWA\DEMO\DEMO.MDB"
  80.       Exclusive       =   0   'False
  81.       Height          =   372
  82.       Left            =   120
  83.       Options         =   0
  84.       ReadOnly        =   0   'False
  85.       RecordSource    =   "PRDGRP"
  86.       Top             =   4560
  87.       Width           =   5052
  88.    End
  89.    Begin Label Label1 
  90.       Caption         =   "&Description:"
  91.       Height          =   252
  92.       Index           =   3
  93.       Left            =   120
  94.       TabIndex        =   7
  95.       Top             =   1200
  96.       Width           =   1092
  97.    End
  98.    Begin Label Label1 
  99.       Caption         =   "&Type:"
  100.       Height          =   252
  101.       Index           =   2
  102.       Left            =   120
  103.       TabIndex        =   5
  104.       Top             =   840
  105.       Width           =   1092
  106.    End
  107.    Begin Label Label1 
  108.       Caption         =   "&Code:"
  109.       Height          =   252
  110.       Index           =   1
  111.       Left            =   120
  112.       TabIndex        =   3
  113.       Top             =   480
  114.       Width           =   1092
  115.    End
  116.    Begin Label Label1 
  117.       Caption         =   "&Group:"
  118.       Height          =   252
  119.       Index           =   0
  120.       Left            =   120
  121.       TabIndex        =   1
  122.       Top             =   120
  123.       Width           =   1092
  124.    End
  125. Option Explicit
  126. ' lInitialize is required as a one time flag,
  127. ' see form_activate() for details
  128. Dim lInitialize As Integer
  129. Sub Brw_Change (nRowCol As Integer)
  130.    Dim cFind As String
  131.    ' reposition the browse control in the frmCatalog
  132.    ' if the form is visible
  133.    ' The 2 databases are related by GROUP+CODE+TYPE
  134.    If frmCatalog.Visible Then
  135.       cFind = "GROUP = '" + dtaPrdGroup.Recordset.Fields("GROUP").Value + "' and "
  136.       cFind = cFind + "CODE = '" + dtaPrdGroup.Recordset.Fields("CODE").Value + "' and "
  137.       cFind = cFind + "TYPE = '" + dtaPrdGroup.Recordset.Fields("TYPE").Value + "'"
  138.       frmCatalog!dtaCatalog.Recordset.FindFirst cFind
  139.    End If
  140. End Sub
  141. Sub Brw_EditValid (nCol As Integer, cField As String, lOk As Integer)
  142.    ' no validation is required, only the product
  143.    ' group description is editable
  144. End Sub
  145. Sub comProducts_Click ()
  146.    ' activate the frmCatalog - the other form
  147.    frmCatalog.Show
  148.    comProducts.Enabled = False
  149. End Sub
  150. Sub Form_Activate ()
  151.    ' We need to force the data control to move to
  152.    ' the first record, after the form has been
  153.    ' loaded (but not in form_load(), the objects
  154.    ' are not yet initialized ).
  155.    ' This must be done also if the RecordSource
  156.    ' changes at run-time
  157.    If Not lInitialize Then
  158.       lInitialize = True
  159.       dtaPrdGroup.Recordset.MoveFirst
  160.    End If
  161. End Sub
  162. Sub Form_Load ()
  163.    Me.Top = 0: Me.Left = 0
  164.    ' initialize the Browse control
  165.    Brw.Cols = 4            ' we need four columns
  166.    ' set columns data width
  167.    Brw.ColWidth(0) = 4
  168.    Brw.ColWidth(1) = 4
  169.    Brw.ColWidth(2) = 4
  170.    Brw.ColWidth(3) = 50
  171.    ' set column headers - defaults are the field names
  172.    Brw.Header(0) = "Group"
  173.    Brw.Header(1) = "Code"
  174.    Brw.Header(2) = "Type"
  175.    Brw.Header(3) = "Description"
  176.    ' set the data field for each column
  177.    Brw.ColField(0) = "GROUP"
  178.    Brw.ColField(1) = "CODE"
  179.    Brw.ColField(2) = "TYPE"
  180.    Brw.ColField(3) = "DESCR"
  181.    Brw.LeftFrozen = 1      ' freeze the GROUP (column 0) to the left
  182.    Brw.ColEdit(3) = True   ' enable editing only for the last column
  183.    Load frmCatalog         ' load the other form, but do not show it
  184. End Sub
  185. Sub Form_Unload (Cancel As Integer)
  186.    ' we are exiting, unload the frmCatalog
  187.    Unload frmCatalog
  188. End Sub
  189.