home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / source / chap27 / frm227.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-28  |  8.1 KB  |  278 lines

  1. VERSION 4.00
  2. Begin VB.Form Form2 
  3.    Caption         =   "Bound Form"
  4.    ClientHeight    =   4785
  5.    ClientLeft      =   1980
  6.    ClientTop       =   1860
  7.    ClientWidth     =   6690
  8.    Height          =   5190
  9.    Left            =   1920
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4785
  12.    ScaleWidth      =   6690
  13.    Top             =   1515
  14.    Width           =   6810
  15.    Begin VB.ComboBox comfield 
  16.       Height          =   315
  17.       Left            =   1560
  18.       Style           =   2  'Dropdown List
  19.       TabIndex        =   19
  20.       Top             =   3120
  21.       Width           =   1875
  22.    End
  23.    Begin VB.TextBox txtcomments 
  24.       Height          =   285
  25.       Left            =   1560
  26.       MultiLine       =   -1  'True
  27.       TabIndex        =   18
  28.       Top             =   2280
  29.       Width           =   4635
  30.    End
  31.    Begin VB.TextBox txtsubject 
  32.       Height          =   285
  33.       Left            =   1560
  34.       MultiLine       =   -1  'True
  35.       TabIndex        =   17
  36.       Top             =   1440
  37.       Width           =   4635
  38.    End
  39.    Begin VB.TextBox txtnotes 
  40.       Height          =   285
  41.       Left            =   1560
  42.       MultiLine       =   -1  'True
  43.       TabIndex        =   14
  44.       Top             =   2700
  45.       Width           =   4635
  46.    End
  47.    Begin VB.TextBox txtdescription 
  48.       Height          =   285
  49.       Left            =   1560
  50.       MultiLine       =   -1  'True
  51.       TabIndex        =   12
  52.       Top             =   1860
  53.       Width           =   4635
  54.    End
  55.    Begin VB.TextBox txtpubid 
  56.       Height          =   285
  57.       Left            =   1560
  58.       MultiLine       =   -1  'True
  59.       TabIndex        =   10
  60.       Top             =   180
  61.       Width           =   855
  62.    End
  63.    Begin VB.TextBox txtisbn 
  64.       Height          =   285
  65.       Left            =   1560
  66.       MultiLine       =   -1  'True
  67.       TabIndex        =   8
  68.       Top             =   600
  69.       Width           =   1635
  70.    End
  71.    Begin VB.TextBox txtyear 
  72.       Height          =   315
  73.       Left            =   5040
  74.       MultiLine       =   -1  'True
  75.       TabIndex        =   6
  76.       Top             =   180
  77.       Width           =   855
  78.    End
  79.    Begin VB.CheckBox chkeof 
  80.       Caption         =   "EOF Reached"
  81.       Enabled         =   0   'False
  82.       Height          =   295
  83.       Left            =   2340
  84.       TabIndex        =   5
  85.       Top             =   3660
  86.       Width           =   1875
  87.    End
  88.    Begin VB.CheckBox chkbof 
  89.       Caption         =   "BOF Reached"
  90.       Enabled         =   0   'False
  91.       Height          =   295
  92.       Left            =   180
  93.       TabIndex        =   4
  94.       Top             =   3660
  95.       Width           =   1875
  96.    End
  97.    Begin VB.CommandButton cmdexit 
  98.       Caption         =   "E&xit"
  99.       Height          =   295
  100.       Left            =   5220
  101.       TabIndex        =   3
  102.       Top             =   4080
  103.       Width           =   1215
  104.    End
  105.    Begin VB.Data Data1 
  106.       Align           =   2  'Align Bottom
  107.       BOFAction       =   1  'BOF
  108.       Caption         =   "Data Control"
  109.       Connect         =   "Access"
  110.       DatabaseName    =   "biblio.mdb"
  111.       EOFAction       =   2  'Add New
  112.       Exclusive       =   0   'False
  113.       Height          =   300
  114.       Left            =   0
  115.       Options         =   0
  116.       ReadOnly        =   0   'False
  117.       RecordsetType   =   1  'Dynaset
  118.       RecordSource    =   ""
  119.       Top             =   4485
  120.       Width           =   6690
  121.    End
  122.    Begin VB.TextBox txttitle 
  123.       Height          =   285
  124.       Left            =   1560
  125.       MultiLine       =   -1  'True
  126.       TabIndex        =   2
  127.       Top             =   1020
  128.       Width           =   4635
  129.    End
  130.    Begin VB.Label Label1 
  131.       Caption         =   "Order by"
  132.       Height          =   285
  133.       Index           =   7
  134.       Left            =   180
  135.       TabIndex        =   20
  136.       Top             =   3180
  137.       Width           =   1215
  138.    End
  139.    Begin VB.Label Label1 
  140.       Caption         =   "Comments"
  141.       Height          =   285
  142.       Index           =   6
  143.       Left            =   180
  144.       TabIndex        =   16
  145.       Top             =   2280
  146.       Width           =   1215
  147.    End
  148.    Begin VB.Label Label1 
  149.       Caption         =   "Notes"
  150.       Height          =   285
  151.       Index           =   5
  152.       Left            =   180
  153.       TabIndex        =   15
  154.       Top             =   2700
  155.       Width           =   1215
  156.    End
  157.    Begin VB.Label Label1 
  158.       Caption         =   "Description"
  159.       Height          =   285
  160.       Index           =   4
  161.       Left            =   180
  162.       TabIndex        =   13
  163.       Top             =   1860
  164.       Width           =   1215
  165.    End
  166.    Begin VB.Label Label1 
  167.       Caption         =   "Pub. ID"
  168.       Height          =   285
  169.       Index           =   3
  170.       Left            =   180
  171.       TabIndex        =   11
  172.       Top             =   180
  173.       Width           =   1215
  174.    End
  175.    Begin VB.Label Label1 
  176.       Caption         =   "ISBN"
  177.       Height          =   285
  178.       Index           =   2
  179.       Left            =   180
  180.       TabIndex        =   9
  181.       Top             =   600
  182.       Width           =   1215
  183.    End
  184.    Begin VB.Label Label1 
  185.       Caption         =   "Year Published"
  186.       Height          =   285
  187.       Index           =   1
  188.       Left            =   3660
  189.       TabIndex        =   7
  190.       Top             =   180
  191.       Width           =   1215
  192.    End
  193.    Begin VB.Label Label2 
  194.       Caption         =   "Subject"
  195.       Height          =   285
  196.       Left            =   180
  197.       TabIndex        =   1
  198.       Top             =   1440
  199.       Width           =   1215
  200.    End
  201.    Begin VB.Label Label1 
  202.       Caption         =   "Title"
  203.       Height          =   285
  204.       Index           =   0
  205.       Left            =   180
  206.       TabIndex        =   0
  207.       Top             =   1020
  208.       Width           =   1215
  209.    End
  210. Attribute VB_Name = "Form2"
  211. Attribute VB_Creatable = False
  212. Attribute VB_Exposed = False
  213. Option Explicit
  214. Function getfield(rs As Recordset, cfield As String) As Variant
  215. If IsNull(rs.Fields(cfield).Value) Then
  216.     Select Case rs.Fields(cfield).Type
  217.         Case dbBoolean
  218.         
  219.             getfield = False
  220.         
  221.         Case dbByte To dbDate
  222.             
  223.             getfield = 0
  224.         
  225.         Case dbLongBinary
  226.         
  227.             getfield = 0&
  228.         
  229.         Case dbMemo, dbText
  230.         
  231.             getfield = ""
  232.     End Select
  233.     getfield = rs.Fields(cfield).Value
  234. End If
  235. End Function
  236. Private Sub cmdexit_Click()
  237. Unload Form2
  238. Set Form2 = Nothing
  239. End Sub
  240. Private Sub comfield_Click()
  241.     If Not comfield.Text = "Comments" Then
  242.         Data1.RecordSource = "select * From titles order by [" & comfield.Text & "]"
  243.         Data1.Refresh
  244.     End If
  245. End Sub
  246. Private Sub Data1_Reposition()
  247. If Data1.Recordset.BOF = True Then
  248.     chkbof.Value = vbChecked
  249.     Exit Sub
  250. End If
  251. If Data1.Recordset.EOF = True Then
  252.     chkeof.Value = vbChecked
  253.     Exit Sub
  254. End If
  255.     chkbof.Value = vbUnchecked
  256.     chkeof.Value = vbUnchecked
  257.     txtcomments.Text = getfield(Data1.Recordset, "comments")
  258.     txtdescription.Text = getfield(Data1.Recordset, "description")
  259.     txtnotes.Text = getfield(Data1.Recordset, "notes")
  260.     txtpubid.Text = getfield(Data1.Recordset, "pubid")
  261.     txtsubject.Text = getfield(Data1.Recordset, "subject")
  262.     txttitle.Text = getfield(Data1.Recordset, "title")
  263.     txtyear.Text = getfield(Data1.Recordset, "[year published]")
  264.     txtisbn.Text = getfield(Data1.Recordset, "isbn")
  265. End Sub
  266. Private Sub Form_Load()
  267.     Dim filepath As String
  268.     Dim x As Integer
  269.     filepath = "\source\chap27\"
  270.     Data1.DatabaseName = filepath & "biblio.mdb"
  271.     Data1.RecordSource = "select * From titles "
  272.     Data1.Refresh
  273.     Data1.Align = 2
  274.     For x = 0 To Data1.Recordset.Fields.Count - 1
  275.         comfield.AddItem Data1.Recordset.Fields(x).Name
  276.     Next x
  277. End Sub
  278.