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

  1. VERSION 5.00
  2. Begin VB.Form AddNew 
  3.    Caption         =   "Add A New Contact"
  4.    ClientHeight    =   2670
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   5205
  8.    LinkTopic       =   "Form2"
  9.    ScaleHeight     =   2670
  10.    ScaleWidth      =   5205
  11.    StartUpPosition =   2  'CenterScreen
  12.    Begin VB.TextBox txtName 
  13.       Height          =   285
  14.       Left            =   120
  15.       TabIndex        =   7
  16.       Top             =   360
  17.       Width           =   4935
  18.    End
  19.    Begin VB.TextBox txtEmail 
  20.       Height          =   285
  21.       Left            =   120
  22.       TabIndex        =   3
  23.       Top             =   1080
  24.       Width           =   4935
  25.    End
  26.    Begin VB.TextBox txtPhone 
  27.       Height          =   285
  28.       Left            =   120
  29.       TabIndex        =   2
  30.       Top             =   1800
  31.       Width           =   4935
  32.    End
  33.    Begin VB.CommandButton AddNewCancel 
  34.       Caption         =   "Cancel"
  35.       Height          =   255
  36.       Left            =   3360
  37.       TabIndex        =   1
  38.       Top             =   2280
  39.       Width           =   975
  40.    End
  41.    Begin VB.CommandButton AddNewOK 
  42.       Caption         =   "OK"
  43.       Height          =   255
  44.       Left            =   4440
  45.       TabIndex        =   0
  46.       Top             =   2280
  47.       Width           =   615
  48.    End
  49.    Begin VB.Label Label1 
  50.       Caption         =   "Name"
  51.       Height          =   255
  52.       Left            =   120
  53.       TabIndex        =   6
  54.       Top             =   120
  55.       Width           =   1215
  56.    End
  57.    Begin VB.Label Label2 
  58.       Caption         =   "Email:"
  59.       Height          =   255
  60.       Left            =   120
  61.       TabIndex        =   5
  62.       Top             =   840
  63.       Width           =   615
  64.    End
  65.    Begin VB.Label Label3 
  66.       Caption         =   "Phone Number:"
  67.       Height          =   255
  68.       Left            =   120
  69.       TabIndex        =   4
  70.       Top             =   1560
  71.       Width           =   1935
  72.    End
  73. Attribute VB_Name = "AddNew"
  74. Attribute VB_GlobalNameSpace = False
  75. Attribute VB_Creatable = False
  76. Attribute VB_PredeclaredId = True
  77. Attribute VB_Exposed = False
  78. Private Sub AddNewCancel_Click()
  79. Close
  80. Unload Me
  81. End Sub
  82. Private Sub AddNewOK_Click()
  83. Dim db As Database
  84. Dim rsNewContact As Recordset
  85. Set db = OpenDatabase(App.Path + "\" + "connections.mdb")
  86. Set rsNewContacts = db.OpenRecordset("Contacts")
  87. rsNewContacts.MoveLast 'moves to spot after the last person in the database
  88. 'the following lines of code are what actually add the user info to the database.
  89. With rsNewContacts
  90.         .AddNew 'creats buffers to hold data to be added to the current recordset
  91.         !Name = Trim(txtName.Text)   'adds txtname.Text to the field name in the database
  92.         !email = Trim(txtEmail.Text) 'adds txtemail.Text to the field email in the database
  93.         !phone = Trim(txtPhone.Text) 'adds txtPhone.Text to the field phone in the database
  94.         .Update ' saves the new contact information
  95. End With
  96. db.Close
  97. MsgBox "New Contact  --  " + txtName.Text + "  --  Was Added Succesfully", vbOKOnly
  98. AddressMain.cmbContacts.AddItem txtName.Text 'adds the new user to the list on the main form
  99. Close
  100. Unload Me
  101. End Sub
  102.