home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / addres1a / addressm.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-15  |  3.6 KB  |  119 lines

  1. VERSION 5.00
  2. Begin VB.Form AddressMain 
  3.    Caption         =   "Address Book Example - PleX"
  4.    ClientHeight    =   2595
  5.    ClientLeft      =   165
  6.    ClientTop       =   450
  7.    ClientWidth     =   6795
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   2595
  10.    ScaleWidth      =   6795
  11.    StartUpPosition =   2  'CenterScreen
  12.    Begin VB.ComboBox cmbContacts 
  13.       Height          =   360
  14.       Left            =   240
  15.       Sorted          =   -1  'True
  16.       Style           =   2  'Dropdown List
  17.       TabIndex        =   1
  18.       Top             =   600
  19.       Width           =   2775
  20.    End
  21.    Begin VB.Frame Frame1 
  22.       Caption         =   "Contacts!"
  23.       Height          =   2535
  24.       Left            =   0
  25.       TabIndex        =   0
  26.       Top             =   0
  27.       Width           =   6735
  28.       Begin VB.TextBox txtPhone 
  29.          Height          =   285
  30.          Left            =   240
  31.          TabIndex        =   6
  32.          Top             =   2040
  33.          Width           =   2775
  34.       End
  35.       Begin VB.TextBox txtEmail 
  36.          Height          =   285
  37.          Left            =   240
  38.          TabIndex        =   4
  39.          Top             =   1320
  40.          Width           =   2775
  41.       End
  42.       Begin VB.Label Label3 
  43.          Caption         =   "Phone Number:"
  44.          Height          =   255
  45.          Left            =   240
  46.          TabIndex        =   5
  47.          Top             =   1800
  48.          Width           =   1935
  49.       End
  50.       Begin VB.Label Label2 
  51.          Caption         =   "Email:"
  52.          Height          =   255
  53.          Left            =   240
  54.          TabIndex        =   3
  55.          Top             =   1080
  56.          Width           =   615
  57.       End
  58.       Begin VB.Label Label1 
  59.          Caption         =   "Name:"
  60.          Height          =   255
  61.          Left            =   240
  62.          TabIndex        =   2
  63.          Top             =   360
  64.          Width           =   855
  65.       End
  66.    End
  67.    Begin VB.Menu mnuFile 
  68.       Caption         =   "&File"
  69.       Begin VB.Menu mnuNewContact 
  70.          Caption         =   "&New Contact"
  71.       End
  72.       Begin VB.Menu mnuSep 
  73.          Caption         =   "-"
  74.       End
  75.       Begin VB.Menu mnuExit 
  76.          Caption         =   "E&xit"
  77.       End
  78.    End
  79. Attribute VB_Name = "AddressMain"
  80. Attribute VB_GlobalNameSpace = False
  81. Attribute VB_Creatable = False
  82. Attribute VB_PredeclaredId = True
  83. Attribute VB_Exposed = False
  84. Dim db As Database
  85. Dim rs As Recordset
  86. Dim rsemail As Recordset
  87. Dim rsphone As Recordset
  88. Private Sub cmbContacts_Click()
  89. On Error Resume Next
  90. Set db = OpenDatabase(App.Path + "\" + "connections.mdb")
  91. Set rsemail = db.OpenRecordset("SELECT contacts.email From contacts WHERE contacts.name = " + Chr$(34) + cmbContacts.Text + Chr$(34) + ";")
  92. Set rsphone = db.OpenRecordset("SELECT contacts.phone From contacts WHERE contacts.name = " + Chr$(34) + cmbContacts.Text + Chr$(34) + ";")
  93. rsemail.MoveFirst
  94. txtEmail.Text = rsemail.Fields("email")
  95. txtPhone.Text = rsphone.Fields("phone")
  96. db.Close
  97. End Sub
  98. Private Sub Form_Load()
  99. Set db = OpenDatabase(App.Path + "\" + "connections.mdb")
  100. Set rs = db.OpenRecordset("Contacts")
  101. rs.MoveFirst
  102. Do Until rs.EOF
  103. cmbContacts.AddItem rs.Fields("Name")
  104. rs.MoveNext
  105. db.Close
  106. End Sub
  107. Private Sub Form_Unload(Cancel As Integer)
  108. Close
  109. End Sub
  110. Private Sub mnuExit_Click()
  111. Close 'this makes sure every thing is closed, just incase the
  112. 'db object didnt close properly for some reason or another
  113. Unload Me
  114. End Sub
  115. Private Sub mnuNewContact_Click()
  116. Load AddNew
  117. AddNew.Show
  118. End Sub
  119.