home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / browse_1 / brwdemo.frm < prev    next >
Text File  |  1993-07-19  |  6KB  |  205 lines

  1. VERSION 2.00
  2. Begin Form BrwDemo 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Product Groups"
  5.    ClientHeight    =   4980
  6.    ClientLeft      =   876
  7.    ClientTop       =   1296
  8.    ClientWidth     =   5280
  9.    Height          =   5316
  10.    Left            =   828
  11.    MaxButton       =   0   'False
  12.    ScaleHeight     =   4980
  13.    ScaleWidth      =   5280
  14.    Top             =   1008
  15.    Width           =   5376
  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. End
  126. Option Explicit
  127.  
  128. ' lInitialize is required as a one time flag,
  129. ' see form_activate() for details
  130. Dim lInitialize As Integer
  131.  
  132. Sub Brw_Change (nRowCol As Integer)
  133.    Dim cFind As String
  134.  
  135.    ' reposition the browse control in the frmCatalog
  136.    ' if the form is visible
  137.    ' The 2 databases are related by GROUP+CODE+TYPE
  138.    If frmCatalog.Visible Then
  139.       cFind = "GROUP = '" + dtaPrdGroup.Recordset.Fields("GROUP").Value + "' and "
  140.       cFind = cFind + "CODE = '" + dtaPrdGroup.Recordset.Fields("CODE").Value + "' and "
  141.       cFind = cFind + "TYPE = '" + dtaPrdGroup.Recordset.Fields("TYPE").Value + "'"
  142.       frmCatalog!dtaCatalog.Recordset.FindFirst cFind
  143.    End If
  144. End Sub
  145.  
  146. Sub Brw_EditValid (nCol As Integer, cField As String, lOk As Integer)
  147.    ' no validation is required, only the product
  148.    ' group description is editable
  149. End Sub
  150.  
  151. Sub comProducts_Click ()
  152.    ' activate the frmCatalog - the other form
  153.    frmCatalog.Show
  154.    comProducts.Enabled = False
  155. End Sub
  156.  
  157. Sub Form_Activate ()
  158.    ' We need to force the data control to move to
  159.    ' the first record, after the form has been
  160.    ' loaded (but not in form_load(), the objects
  161.    ' are not yet initialized ).
  162.    ' This must be done also if the RecordSource
  163.    ' changes at run-time
  164.    If Not lInitialize Then
  165.       lInitialize = True
  166.       dtaPrdGroup.Recordset.MoveFirst
  167.    End If
  168. End Sub
  169.  
  170. Sub Form_Load ()
  171.    Me.Top = 0: Me.Left = 0
  172.    
  173.    ' initialize the Browse control
  174.    Brw.Cols = 4            ' we need four columns
  175.    
  176.    ' set columns data width
  177.    Brw.ColWidth(0) = 4
  178.    Brw.ColWidth(1) = 4
  179.    Brw.ColWidth(2) = 4
  180.    Brw.ColWidth(3) = 50
  181.  
  182.    ' set column headers - defaults are the field names
  183.    Brw.Header(0) = "Group"
  184.    Brw.Header(1) = "Code"
  185.    Brw.Header(2) = "Type"
  186.    Brw.Header(3) = "Description"
  187.    
  188.    ' set the data field for each column
  189.    Brw.ColField(0) = "GROUP"
  190.    Brw.ColField(1) = "CODE"
  191.    Brw.ColField(2) = "TYPE"
  192.    Brw.ColField(3) = "DESCR"
  193.    
  194.    Brw.LeftFrozen = 1      ' freeze the GROUP (column 0) to the left
  195.    Brw.ColEdit(3) = True   ' enable editing only for the last column
  196.  
  197.    Load frmCatalog         ' load the other form, but do not show it
  198. End Sub
  199.  
  200. Sub Form_Unload (Cancel As Integer)
  201.    ' we are exiting, unload the frmCatalog
  202.    Unload frmCatalog
  203. End Sub
  204.  
  205.