home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vidlibp / vidgrid.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-01  |  9.7 KB  |  310 lines

  1. VERSION 2.00
  2. Begin Form VidGrid 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   0  'None
  5.    Caption         =   "Find Video Record"
  6.    ClientHeight    =   5550
  7.    ClientLeft      =   90
  8.    ClientTop       =   1545
  9.    ClientWidth     =   9435
  10.    Height          =   5955
  11.    HelpContextID   =   235
  12.    Left            =   30
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   5550
  17.    ScaleWidth      =   9435
  18.    Top             =   1200
  19.    Width           =   9555
  20.    WindowState     =   2  'Maximized
  21.    Begin TextBox txtTape 
  22.       DataField       =   "RecCode"
  23.       DataSource      =   "dtaVideo"
  24.       Height          =   615
  25.       Left            =   8595
  26.       TabIndex        =   9
  27.       TabStop         =   0   'False
  28.       Top             =   3975
  29.       Visible         =   0   'False
  30.       Width           =   645
  31.    End
  32.    Begin TextBox txtTime 
  33.       DataField       =   "RunTime"
  34.       DataSource      =   "dtaVideo"
  35.       Height          =   615
  36.       Left            =   8595
  37.       TabIndex        =   8
  38.       TabStop         =   0   'False
  39.       Top             =   3225
  40.       Visible         =   0   'False
  41.       Width           =   645
  42.    End
  43.    Begin TextBox txtYear 
  44.       DataField       =   "RlsYear"
  45.       DataSource      =   "dtaVideo"
  46.       Height          =   615
  47.       Left            =   8595
  48.       TabIndex        =   7
  49.       TabStop         =   0   'False
  50.       Text            =   " "
  51.       Top             =   2475
  52.       Visible         =   0   'False
  53.       Width           =   645
  54.    End
  55.    Begin CommandButton cmdPageForward 
  56.       Caption         =   ">"
  57.       Height          =   270
  58.       Left            =   6705
  59.       TabIndex        =   5
  60.       Top             =   375
  61.       Width           =   285
  62.    End
  63.    Begin CommandButton cmdPageBack 
  64.       Caption         =   "<"
  65.       Height          =   270
  66.       Left            =   1215
  67.       TabIndex        =   6
  68.       Top             =   375
  69.       Width           =   285
  70.    End
  71.    Begin TextBox txtName 
  72.       DataField       =   "VidName"
  73.       DataSource      =   "dtaVideo"
  74.       Height          =   615
  75.       Left            =   8595
  76.       TabIndex        =   4
  77.       TabStop         =   0   'False
  78.       Top             =   1725
  79.       Visible         =   0   'False
  80.       Width           =   645
  81.    End
  82.    Begin TextBox txtCode 
  83.       DataField       =   "VidCode"
  84.       DataSource      =   "dtaVideo"
  85.       Height          =   615
  86.       Left            =   8595
  87.       TabIndex        =   3
  88.       TabStop         =   0   'False
  89.       Top             =   975
  90.       Visible         =   0   'False
  91.       Width           =   645
  92.    End
  93.    Begin Data dtaVideo 
  94.       Connect         =   ""
  95.       DatabaseName    =   "VIDLIB.MDB"
  96.       Exclusive       =   0   'False
  97.       Height          =   270
  98.       Left            =   1485
  99.       Options         =   0
  100.       ReadOnly        =   -1  'True
  101.       RecordSource    =   "Video"
  102.       Top             =   375
  103.       Width           =   5235
  104.    End
  105.    Begin CommandButton cmdDone 
  106.       Caption         =   "&Done"
  107.       Height          =   465
  108.       HelpContextID   =   235
  109.       Left            =   8235
  110.       TabIndex        =   0
  111.       Top             =   150
  112.       Width           =   1185
  113.    End
  114.    Begin Grid grdVideo 
  115.       BackColor       =   &H00FFFF00&
  116.       Cols            =   5
  117.       FixedCols       =   0
  118.       Height          =   6090
  119.       HelpContextID   =   235
  120.       HighLight       =   0   'False
  121.       Left            =   180
  122.       TabIndex        =   1
  123.       Top             =   825
  124.       Width           =   9255
  125.    End
  126.    Begin Label lblData 
  127.       BackColor       =   &H00FFFF00&
  128.       BorderStyle     =   1  'Fixed Single
  129.       Height          =   240
  130.       Left            =   1215
  131.       TabIndex        =   2
  132.       Top             =   150
  133.       Width           =   5775
  134.    End
  135. ' Subsystem: Edit
  136. ' Module:    VidGrid.Frm
  137. ' Date:      01/02/94
  138. ' Author:    Richard Stauch
  139. ' Notes:
  140. ' This form displays up to MAXROW rows of data from the Video
  141. ' table. The user can scroll through the data, and can select
  142. ' a row making it the current record. The current record is
  143. ' always displayed in the top row.
  144. ' The module-level variables RepoFlag, DataMove and GridFill
  145. ' work together to prevent recursion into the FillGrid procedure
  146. ' when moving through the data normally, or when a record is
  147. ' read paging up or down.
  148. Option Explicit
  149. DefInt A-Z
  150. ' Constants
  151. Const MAXROW = 24 ' The Maximum data rows.
  152. ' Variables
  153. Dim RepoFlag As Integer ' Reposition flag.
  154. Dim DataMove As Integer ' Data Move flag.
  155. Dim GridFill As Integer ' Grid Fill flag.
  156. Sub cmdDone_Click ()
  157. ' Remove the grid form, and return to the calling form.
  158.   Unload VidGrid
  159. End Sub
  160. Sub cmdPageBack_Click ()
  161. ' Perform the MovePrevious method up to MAXROWs.
  162. Dim I As Integer  ' Counter to read MAXROWs.
  163. ' Prevent the system from filling the grid until we're done.
  164.   GridFill% = True
  165.   RepoFlag% = True
  166. ' Read backward until we reach MAXROW, or beginning-of-file.
  167.   Do Until dtaVideo.Recordset.BOF Or I% = MAXROW
  168.   ' Capture the current record code before moving.
  169.     CurrentRecordCode$ = txtCode.Text
  170.     dtaVideo.Recordset.MovePrevious
  171.     I% = I% + 1
  172.   Loop
  173. ' We have the code, now fill the grid.
  174.   GridFill% = False
  175.   RepoFlag% = False
  176.   dtaVideo.Recordset.FindFirst "VidCode = '" + CurrentRecordCode$ + "'"
  177. End Sub
  178. Sub cmdPageForward_Click ()
  179. ' Perform the MoveNext method up to MAXROWs.
  180. Dim I As Integer  ' Counter to read MAXROWS.
  181. ' Prevent the system from filling the grid until we're done.
  182.   GridFill% = True
  183.   RepoFlag% = True
  184. ' Read forward until we reach MAXROW, or end-of-file.
  185.   Do Until dtaVideo.Recordset.EOF Or I% = MAXROW
  186.   ' Capture the current record before moving.
  187.     CurrentRecordCode$ = txtCode.Text
  188.     dtaVideo.Recordset.MoveNext
  189.     I% = I% + 1
  190.   Loop
  191. ' We have the code, now fill the grid.
  192.   GridFill% = False
  193.   RepoFlag% = False
  194.   dtaVideo.Recordset.FindFirst "VidCode = '" + CurrentRecordCode$ + "'"
  195. End Sub
  196. Sub dtaVideo_Reposition ()
  197. ' Data control has repositioned.
  198.   If DataMove% = True And GridFill% = False Then
  199.   ' The user has clicked the data control, or we're paging.
  200.     CurrentRecordCode$ = txtCode.Text
  201.     DataMove% = False
  202.   End If
  203.   If RepoFlag% = False Then
  204.   ' Don't call FillGrid recursively.
  205.     RepoFlag% = True
  206.     FillGrid
  207.     RepoFlag% = False
  208.   End If
  209. End Sub
  210. Sub dtaVideo_Validate (Action As Integer, Save As Integer)
  211. ' Data control Validate event.
  212.   Select Case Action
  213.     Case DATA_ACTIONUNLOAD
  214.     ' The user clicked the Done command button.
  215.       CurrentRecordCode$ = txtCode.Text
  216.     Case DATA_ACTIONMOVEFIRST, DATA_ACTIONMOVEPREVIOUS, DATA_ACTIONMOVENEXT, DATA_ACTIONMOVELAST
  217.     ' We're moving the record pointer.
  218.       DataMove% = True
  219.   End Select
  220. End Sub
  221. Sub FillGrid ()
  222. ' Fill the grid control starting with the current record.
  223. Dim I As Integer
  224. ' Prevent the Reposition event from calling this procedure.
  225.   GridFill% = True
  226. ' Maximize the grid rows.
  227.   grdVideo.Rows = MAXROW + 1
  228. ' Begin with the current record.
  229.   dtaVideo.Recordset.FindFirst "VidCode = '" + CurrentRecordCode$ + "'"
  230. ' Point to the first column.
  231.   grdVideo.Col = 0
  232. ' Point to the first row.
  233.   I% = 0
  234.   Do Until dtaVideo.Recordset.EOF Or I% = MAXROW
  235.     I% = I% + 1 ' Increment the row counter.
  236.     grdVideo.Row = I% ' Point to the current row.
  237.   ' Now set the text of each cell with the bound control texts.
  238.     grdVideo.Text = txtCode.Text
  239.     grdVideo.Col = 1
  240.     grdVideo.Text = txtName.Text
  241.     grdVideo.Col = 2
  242.     grdVideo.Text = txtYear.Text
  243.     grdVideo.Col = 3
  244.     grdVideo.Text = txtTime.Text
  245.     grdVideo.Col = 4
  246.     grdVideo.Text = txtTape.Text
  247.     grdVideo.Col = 0 ' Reset the column.
  248.     dtaVideo.Recordset.MoveNext ' Read the next record.
  249.   Loop
  250. ' Make sure there are no blank rows.
  251.   If I% < MAXROW Then
  252.     grdVideo.Rows = I% + 1
  253.   End If
  254. ' Reset the current record.
  255.   dtaVideo.Recordset.FindFirst "VidCode = '" + CurrentRecordCode$ + "'"
  256. ' This may be a multi-user environment, so make sure
  257. ' the record is still valid.
  258.   If dtaVideo.Recordset.EOF Then
  259.     dtaVideo.Recordset.MoveLast
  260.   End If
  261. ' Allow the grid fill procedure.
  262.   GridFill% = False
  263. End Sub
  264. Sub Form_Load ()
  265. ' Load the grid form.
  266. ' Set column widths as necessary.
  267.   grdVideo.ColWidth(0) = 2170 ' ISBN column.
  268.   grdVideo.ColWidth(1) = 5310 ' Title column.
  269. ' Set titles and alignment for each row.
  270.   grdVideo.Row = 0
  271.   grdVideo.Col = 0
  272.   grdVideo.Text = "ISBN, or Code"
  273.   grdVideo.Col = 1
  274.   grdVideo.Text = "Video Title"
  275.   grdVideo.Col = 2
  276.   grdVideo.Text = "Year"
  277.   grdVideo.FixedAlignment(2) = 1
  278.   grdVideo.ColAlignment(2) = 1
  279.   grdVideo.Col = 3
  280.   grdVideo.Text = "Time"
  281.   grdVideo.FixedAlignment(3) = 1
  282.   grdVideo.ColAlignment(3) = 1
  283.   grdVideo.Col = 4
  284.   grdVideo.Text = "Tape"
  285.   grdVideo.FixedAlignment(4) = 2
  286.   grdVideo.ColAlignment(4) = 2
  287. ' Initialize flags.
  288.   RepoFlag% = False
  289.   DataMove% = False
  290.   GridFill% = False
  291. ' Initialize the record set.
  292.   dtaVideo.Refresh
  293.   If dtaVideo.Recordset.EOF Then
  294.   ' There are no records to display.
  295.     lblData.Caption = "Press Done."
  296.     dtaVideo.Caption = "No records to show."
  297.   Else
  298.   ' Inform the user how to move around in the grid.
  299.     lblData.Caption = "Use the Data Control, or Double-Click the Grid."
  300.     dtaVideo.Caption = "Reviewing key data."
  301.   End If
  302. End Sub
  303. Sub grdVideo_DblClick ()
  304. ' The user double-clicked the grid control.
  305.   grdVideo.Col = 0 ' Point to the first column.
  306. ' Refill the grid.
  307.   CurrentRecordCode$ = grdVideo.Text
  308.   dtaVideo.Recordset.FindFirst "VidCode = '" + CurrentRecordCode$ + "'"
  309. End Sub
  310.