home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / source / chap21 / frm1221.frm (.txt) < prev    next >
Visual Basic Form  |  1995-10-11  |  3KB  |  90 lines

  1. VERSION 4.00
  2. Begin VB.Form frmoutline 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   5940
  5.    ClientLeft      =   1140
  6.    ClientTop       =   1515
  7.    ClientWidth     =   6690
  8.    Height          =   6375
  9.    Left            =   1080
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5940
  12.    ScaleWidth      =   6690
  13.    Top             =   1140
  14.    Width           =   6810
  15.    Begin MSOutl.Outline Outline1 
  16.       Height          =   4455
  17.       Left            =   540
  18.       TabIndex        =   0
  19.       Top             =   480
  20.       Width           =   4575
  21.       _version        =   65536
  22.       _extentx        =   8070
  23.       _extenty        =   7858
  24.       _stockprops     =   77
  25.       mouseicon       =   "FRM1221.frx":0000
  26.       pictureplus     =   "FRM1221.frx":001C
  27.       pictureminus    =   "FRM1221.frx":018E
  28.       pictureleaf     =   "FRM1221.frx":0300
  29.       pictureopen     =   "FRM1221.frx":0472
  30.       pictureclosed   =   "FRM1221.frx":05E4
  31.    End
  32. Attribute VB_Name = "frmoutline"
  33. Attribute VB_Creatable = False
  34. Attribute VB_Exposed = False
  35. Option Explicit
  36. Dim ws As Workspace
  37. Dim db As Database
  38. Private Sub Form_Load()
  39. Dim rs As Recordset
  40. Set ws = DBEngine.CreateWorkspace("ws1", "Admin", "")
  41. Set db = ws.OpenDatabase("biblio.mdb", False, False)
  42. Set rs = db.OpenRecordset("Select * from publishers order by name", dbOpenDynaset)
  43. 'load the Publishers into the outline control
  44. Do While rs.EOF = False
  45.     If Not IsNull(rs("name")) Then
  46.         Outline1.AddItem rs("name")
  47.     End If
  48.     rs.MoveNext
  49. End Sub
  50. Private Sub Outline1_DblClick()
  51. Dim rs As Recordset
  52. Dim rspub As Dynaset
  53. If Outline1.Indent(Outline1.ListIndex) <> 1 Then
  54.     Exit Sub
  55. End If
  56. If Outline1.HasSubItems(Outline1.ListIndex) = False Then
  57.     Set rspub = db.OpenRecordset("select * from publishers where name ='" & Outline1.List(Outline1.ListIndex) & "'", dbOpenDynaset)
  58.     If rspub.RecordCount > 0 Then
  59.         Set rs = db.OpenRecordset("select * from titles where pubid = " & rspub("pubid"), dbOpenDynaset)
  60.            
  61.         If rs.RecordCount = 0 Then
  62.             
  63.             Exit Sub
  64.         
  65.         End If
  66.         
  67.         Do While rs.EOF = False
  68.             
  69.             Outline1.AddItem rs("title"), Outline1.ListIndex + 1
  70.             Outline1.Indent(Outline1.ListIndex + 1) = 2
  71.             rs.MoveNext
  72.         
  73.         Loop
  74.         
  75.             
  76.     End If
  77. End If
  78. Outline1.Expand(Outline1.ListIndex) = True
  79. End Sub
  80. Private Sub Outline1_KeyPress(KeyAscii As Integer)
  81. Select Case KeyAscii
  82. Case 13
  83.     If Outline1.Expand(Outline1.ListIndex) = False Then
  84.         Outline1_DblClick
  85.     Else
  86.         Outline1.Expand(Outline1.ListIndex) = False
  87.     End If
  88. End Select
  89. End Sub
  90.