home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Programmer'…arterly (Limited Edition) / Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso / code / ch04code / chapter4.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-08-15  |  10.5 KB  |  364 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Customer Data Entry"
  4.    ClientHeight    =   4560
  5.    ClientLeft      =   1200
  6.    ClientTop       =   1605
  7.    ClientWidth     =   6630
  8.    Height          =   5025
  9.    Left            =   1110
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4560
  12.    ScaleWidth      =   6630
  13.    Top             =   1230
  14.    Width           =   6810
  15.    Begin VB.PictureBox Picture2 
  16.       Height          =   1215
  17.       Left            =   360
  18.       ScaleHeight     =   1185
  19.       ScaleWidth      =   5985
  20.       TabIndex        =   0
  21.       Top             =   2640
  22.       Width           =   6015
  23.       Begin VB.CommandButton Command10 
  24.          Caption         =   "Delete Record"
  25.          Height          =   375
  26.          Left            =   4080
  27.          TabIndex        =   25
  28.          Top             =   720
  29.          Width           =   1575
  30.       End
  31.       Begin VB.CommandButton Command9 
  32.          Caption         =   "Seek Name"
  33.          Height          =   375
  34.          Left            =   4680
  35.          TabIndex        =   24
  36.          Top             =   120
  37.          Width           =   1095
  38.       End
  39.       Begin VB.CommandButton Command8 
  40.          Caption         =   "Edit Record"
  41.          Height          =   375
  42.          Left            =   2280
  43.          TabIndex        =   6
  44.          Top             =   720
  45.          Width           =   1455
  46.       End
  47.       Begin VB.CommandButton Command7 
  48.          Caption         =   "Add New Record"
  49.          Height          =   375
  50.          Left            =   240
  51.          TabIndex        =   5
  52.          Top             =   720
  53.          Width           =   1575
  54.       End
  55.       Begin VB.CommandButton Command6 
  56.          Caption         =   "Bottom"
  57.          Height          =   375
  58.          Left            =   3600
  59.          TabIndex        =   4
  60.          Top             =   120
  61.          Width           =   855
  62.       End
  63.       Begin VB.CommandButton Command5 
  64.          Caption         =   "Next"
  65.          Height          =   375
  66.          Left            =   2520
  67.          TabIndex        =   3
  68.          Top             =   120
  69.          Width           =   855
  70.       End
  71.       Begin VB.CommandButton Command4 
  72.          Caption         =   "Previous"
  73.          Height          =   375
  74.          Left            =   1320
  75.          TabIndex        =   2
  76.          Top             =   120
  77.          Width           =   975
  78.       End
  79.       Begin VB.CommandButton Command3 
  80.          Caption         =   "Top"
  81.          Height          =   375
  82.          Left            =   240
  83.          TabIndex        =   1
  84.          Top             =   120
  85.          Width           =   855
  86.       End
  87.    End
  88.    Begin VB.TextBox Text1 
  89.       Height          =   285
  90.       Index           =   6
  91.       Left            =   1680
  92.       TabIndex        =   23
  93.       Text            =   "Text1"
  94.       Top             =   2040
  95.       Width           =   1095
  96.    End
  97.    Begin VB.TextBox Text1 
  98.       Height          =   285
  99.       Index           =   5
  100.       Left            =   4560
  101.       TabIndex        =   22
  102.       Text            =   "Text1"
  103.       Top             =   1440
  104.       Width           =   735
  105.    End
  106.    Begin VB.TextBox Text1 
  107.       Height          =   285
  108.       Index           =   4
  109.       Left            =   2880
  110.       TabIndex        =   21
  111.       Text            =   "Text1"
  112.       Top             =   1440
  113.       Width           =   375
  114.    End
  115.    Begin VB.TextBox Text1 
  116.       Height          =   285
  117.       Index           =   3
  118.       Left            =   840
  119.       TabIndex        =   20
  120.       Text            =   "Text1"
  121.       Top             =   1440
  122.       Width           =   1095
  123.    End
  124.    Begin VB.TextBox Text1 
  125.       Height          =   285
  126.       Index           =   2
  127.       Left            =   1200
  128.       TabIndex        =   19
  129.       Text            =   "Text1"
  130.       Top             =   960
  131.       Width           =   1455
  132.    End
  133.    Begin VB.TextBox Text1 
  134.       Height          =   285
  135.       Index           =   1
  136.       Left            =   4320
  137.       TabIndex        =   18
  138.       Text            =   "Text1"
  139.       Top             =   480
  140.       Width           =   1455
  141.    End
  142.    Begin VB.TextBox Text1 
  143.       Height          =   285
  144.       Index           =   0
  145.       Left            =   1320
  146.       TabIndex        =   17
  147.       Text            =   "Text1"
  148.       Top             =   480
  149.       Width           =   1455
  150.    End
  151.    Begin VB.PictureBox Picture3 
  152.       Height          =   855
  153.       Left            =   600
  154.       ScaleHeight     =   825
  155.       ScaleWidth      =   5265
  156.       TabIndex        =   7
  157.       Top             =   2640
  158.       Visible         =   0   'False
  159.       Width           =   5295
  160.       Begin VB.CommandButton Command2 
  161.          Caption         =   "Cancel Edit"
  162.          Height          =   375
  163.          Left            =   3240
  164.          TabIndex        =   9
  165.          Top             =   240
  166.          Width           =   1695
  167.       End
  168.       Begin VB.CommandButton Command1 
  169.          Caption         =   "Save Changes"
  170.          Height          =   375
  171.          Left            =   240
  172.          TabIndex        =   8
  173.          Top             =   240
  174.          Width           =   1815
  175.       End
  176.    End
  177.    Begin VB.Label Label7 
  178.       Caption         =   "Phone Number:"
  179.       Height          =   255
  180.       Left            =   360
  181.       TabIndex        =   16
  182.       Top             =   2040
  183.       Width           =   1215
  184.    End
  185.    Begin VB.Label Label6 
  186.       Caption         =   "Zip Code:"
  187.       Height          =   255
  188.       Left            =   3720
  189.       TabIndex        =   15
  190.       Top             =   1440
  191.       Width           =   855
  192.    End
  193.    Begin VB.Label Label5 
  194.       Caption         =   "State:"
  195.       Height          =   255
  196.       Left            =   2280
  197.       TabIndex        =   14
  198.       Top             =   1440
  199.       Width           =   495
  200.    End
  201.    Begin VB.Label Label4 
  202.       Caption         =   "City:"
  203.       Height          =   255
  204.       Left            =   360
  205.       TabIndex        =   13
  206.       Top             =   1440
  207.       Width           =   495
  208.    End
  209.    Begin VB.Label Label3 
  210.       Caption         =   "Address:"
  211.       Height          =   255
  212.       Left            =   360
  213.       TabIndex        =   12
  214.       Top             =   960
  215.       Width           =   735
  216.    End
  217.    Begin VB.Label Label2 
  218.       Caption         =   "First Name:"
  219.       Height          =   255
  220.       Left            =   3240
  221.       TabIndex        =   11
  222.       Top             =   480
  223.       Width           =   975
  224.    End
  225.    Begin VB.Label Label1 
  226.       Caption         =   "Last Name:"
  227.       Height          =   255
  228.       Left            =   360
  229.       TabIndex        =   10
  230.       Top             =   480
  231.       Width           =   975
  232.    End
  233. Attribute VB_Name = "Form1"
  234. Attribute VB_Creatable = False
  235. Attribute VB_Exposed = False
  236. Dim OldDb As DATABASE, RcSet As Recordset
  237. Dim Addfl As Integer, Addrc As String
  238. Sub Showfields()
  239.     Text1(0).TEXT = IIf(IsNull(RcSet("Lastname")), " ", RcSet("Lastname"))
  240.     Text1(1).TEXT = IIf(IsNull(RcSet("Firstname")), " ", RcSet("Firstname"))
  241.     Text1(2).TEXT = IIf(IsNull(RcSet("Address")), " ", RcSet("Address"))
  242.     Text1(3).TEXT = IIf(IsNull(RcSet("City")), " ", RcSet("City"))
  243.     Text1(4).TEXT = IIf(IsNull(RcSet("State")), " ", RcSet("State"))
  244.     Text1(5).TEXT = IIf(IsNull(RcSet("Zip")), " ", RcSet("Zip"))
  245.     Text1(6).TEXT = IIf(IsNull(RcSet("Phone")), " ", RcSet("Phone"))
  246. End Sub
  247. Private Sub Command1_Click()
  248.     Picture3.Visible = False
  249.     Picture2.Visible = True
  250.     For I = 0 To 6
  251.        Text1(I).ForeColor = &HFF0000
  252.     Next I
  253.     RcSet("Lastname") = Left(Text1(0).TEXT, 30)
  254.     RcSet("Firstname") = Left(Text1(1).TEXT, 30)
  255.     RcSet("Address") = Left(Text1(2).TEXT, 40)
  256.     RcSet("City") = Left(Text1(3).TEXT, 30)
  257.     RcSet("State") = Left(Text1(4).TEXT, 2)
  258.     RcSet("Zip") = Left(Text1(5).TEXT, 5)
  259.     RcSet("Phone") = Left(Text1(6).TEXT, 13)
  260.     RcSet.UPDATE
  261. End Sub
  262. Private Sub Command10_Click()
  263.     If MsgBox("Are you sure you want to delete this record?", 4) = 6 Then
  264.         RcSet.DELETE
  265.         If Not RcSet.EOF Then
  266.             RcSet.MoveNext
  267.         Else
  268.             RcSet.MovePrevious
  269.         End If
  270.         Call Showfields
  271.     End If
  272. End Sub
  273. Private Sub Command2_Click()
  274.     Picture3.Visible = False
  275.     Picture2.Visible = True
  276.     For I = 0 To 6
  277.        Text1(I).ForeColor = &HFF0000
  278.     Next I
  279.     If Addfl Then
  280.        RcSet.Bookmark = Addrc
  281.     End If
  282.     Call Showfields
  283. End Sub
  284. Private Sub Command3_Click()
  285.     RcSet.MoveFirst
  286.     Command4.Enabled = False
  287.     Command5.Enabled = True
  288.     Call Showfields
  289. End Sub
  290. Private Sub Command4_Click()
  291.     RcSet.MovePrevious
  292.     If RcSet.BOF Then
  293.        RcSet.MoveFirst
  294.        Command4.Enabled = False
  295.     End If
  296.     Command5.Enabled = True
  297.     Call Showfields
  298. End Sub
  299. Private Sub Command5_Click()
  300.     RcSet.MoveNext
  301.     If RcSet.EOF Then
  302.         RcSet.MoveLast
  303.         Command5.Enabled = False
  304.     End If
  305.     Command4.Enabled = True
  306.     Call Showfields
  307. End Sub
  308. Private Sub Command6_Click()
  309.     RcSet.MoveLast
  310.     Command4.Enabled = True
  311.     Command5.Enabled = False
  312.     Call Showfields
  313. End Sub
  314. Private Sub Command7_Click()
  315.     Picture2.Visible = False
  316.     Picture3.Visible = True
  317.     Addfl = True
  318.     Addrc = RcSet.Bookmark
  319.     RcSet.AddNew
  320.     Text1(0).TEXT = "  "
  321.     Text1(1).TEXT = "  "
  322.     Text1(2).TEXT = "  "
  323.     Text1(3).TEXT = "  "
  324.     Text1(4).TEXT = "  "
  325.     Text1(5).TEXT = "  "
  326.     Text1(6).TEXT = "  "
  327.     For I = 0 To 6
  328.        Text1(I).ForeColor = &HFF&
  329.     Next I
  330. End Sub
  331. Private Sub Command8_Click()
  332.     Picture2.Visible = False
  333.     Picture3.Visible = True
  334.     For I = 0 To 6
  335.        Text1(I).ForeColor = &HFF&
  336.     Next I
  337.     RcSet.Edit
  338. End Sub
  339. Private Sub Command9_Click()
  340.     Dim addrc2 As String
  341.     addrc2 = RcSet.Bookmark
  342.     Form2.Show 1
  343.     If Seekac = 1 Then
  344.         RcSet.Seek ">=", Seeknm
  345.         If RcSet.NoMatch Then
  346.             RcSet.Bookmark = addrc2
  347.         End If
  348.     End If
  349.     Call Showfields
  350. End Sub
  351. Private Sub Form_Load()
  352.     dbname = App.Path & "\CHAPTER4.MDB"
  353.     Set OldDb = OpenDatabase(dbname)
  354.     Set RcSet = OldDb.OpenRecordset("Customers", dbOpenTable)
  355.     RcSet.Index = "Name"
  356.     RcSet.MoveFirst
  357.     Call Showfields
  358.     Command4.Enabled = False
  359.     For I = 0 To 6
  360. '       Text1(I).Enabled = False
  361.        Text1(I).ForeColor = &HFF0000
  362.     Next I
  363. End Sub
  364.