home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Power Pack / Visual_Basic4_Power_Pack.bin / vb4files / dbawarco / custdtls.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-11-20  |  27.6 KB  |  846 lines

  1. VERSION 4.00
  2. Begin VB.Form CustomersAndAddresses 
  3.    Caption         =   "Customers And Addresses"
  4.    ClientHeight    =   6000
  5.    ClientLeft      =   255
  6.    ClientTop       =   660
  7.    ClientWidth     =   8865
  8.    Height          =   6405
  9.    Left            =   195
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6000
  12.    ScaleWidth      =   8865
  13.    Top             =   315
  14.    Width           =   8985
  15.    Begin VB.Data Data3 
  16.       Caption         =   "Data3"
  17.       Connect         =   "Access"
  18.       DatabaseName    =   "VB4OO.mdb"
  19.       Exclusive       =   0   'False
  20.       Height          =   300
  21.       Left            =   7920
  22.       Options         =   0
  23.       ReadOnly        =   -1  'True
  24.       RecordsetType   =   1  'Dynaset
  25.       RecordSource    =   "Phones"
  26.       Top             =   1800
  27.       Visible         =   0   'False
  28.       Width           =   1140
  29.    End
  30.    Begin VB.CommandButton pbOK 
  31.       Cancel          =   -1  'True
  32.       Caption         =   "OK"
  33.       Default         =   -1  'True
  34.       Height          =   375
  35.       Left            =   7800
  36.       TabIndex        =   11
  37.       Top             =   2280
  38.       Width           =   975
  39.    End
  40.    Begin VB.CommandButton pbDeleteCustomer 
  41.       Caption         =   "Delete"
  42.       Height          =   375
  43.       Left            =   7800
  44.       TabIndex        =   10
  45.       Top             =   1200
  46.       Width           =   975
  47.    End
  48.    Begin VB.CommandButton pbUpdateCustomer 
  49.       Caption         =   "Update"
  50.       Height          =   375
  51.       Left            =   7800
  52.       TabIndex        =   9
  53.       Top             =   720
  54.       Width           =   975
  55.    End
  56.    Begin VB.CommandButton pbAddNewCustomer 
  57.       Caption         =   "Add New"
  58.       Height          =   375
  59.       Left            =   7800
  60.       TabIndex        =   8
  61.       Top             =   240
  62.       Width           =   975
  63.    End
  64.    Begin VB.Frame Frame1 
  65.       Caption         =   "Customer Details"
  66.       Height          =   2535
  67.       Left            =   4440
  68.       TabIndex        =   31
  69.       Top             =   120
  70.       Width           =   3255
  71.       Begin VB.TextBox efCustomerNumber 
  72.          Height          =   285
  73.          Left            =   1200
  74.          TabIndex        =   1
  75.          Top             =   360
  76.          Width           =   1815
  77.       End
  78.       Begin VB.TextBox efSex 
  79.          Height          =   285
  80.          Left            =   2640
  81.          TabIndex        =   7
  82.          Top             =   2160
  83.          Width           =   375
  84.       End
  85.       Begin VB.TextBox efMaritalStatus 
  86.          Height          =   285
  87.          Left            =   1200
  88.          TabIndex        =   6
  89.          Top             =   2160
  90.          Width           =   735
  91.       End
  92.       Begin VB.TextBox efDateOfBirth 
  93.          Height          =   285
  94.          Left            =   1200
  95.          TabIndex        =   5
  96.          Top             =   1800
  97.          Width           =   1815
  98.       End
  99.       Begin VB.TextBox efFirstName 
  100.          Height          =   285
  101.          Left            =   1200
  102.          TabIndex        =   2
  103.          Top             =   720
  104.          Width           =   1815
  105.       End
  106.       Begin VB.TextBox efLastName 
  107.          Height          =   285
  108.          Left            =   1200
  109.          TabIndex        =   3
  110.          Top             =   1080
  111.          Width           =   1815
  112.       End
  113.       Begin VB.TextBox efSSN 
  114.          Height          =   285
  115.          Left            =   1200
  116.          TabIndex        =   4
  117.          Top             =   1440
  118.          Width           =   1815
  119.       End
  120.       Begin VB.Label Label1 
  121.          Caption         =   "Cust Number"
  122.          Height          =   255
  123.          Index           =   12
  124.          Left            =   120
  125.          TabIndex        =   38
  126.          Top             =   360
  127.          Width           =   975
  128.       End
  129.       Begin VB.Label Label1 
  130.          Caption         =   "Sex"
  131.          Height          =   255
  132.          Index           =   11
  133.          Left            =   2160
  134.          TabIndex        =   37
  135.          Top             =   2160
  136.          Width           =   375
  137.       End
  138.       Begin VB.Label Label1 
  139.          Caption         =   "Marital Status"
  140.          Height          =   255
  141.          Index           =   4
  142.          Left            =   120
  143.          TabIndex        =   36
  144.          Top             =   2160
  145.          Width           =   975
  146.       End
  147.       Begin VB.Label Label1 
  148.          Caption         =   "Date Of Birth"
  149.          Height          =   255
  150.          Index           =   3
  151.          Left            =   120
  152.          TabIndex        =   35
  153.          Top             =   1800
  154.          Width           =   975
  155.       End
  156.       Begin VB.Label Label1 
  157.          Caption         =   "First Name"
  158.          Height          =   255
  159.          Index           =   0
  160.          Left            =   120
  161.          TabIndex        =   34
  162.          Top             =   720
  163.          Width           =   975
  164.       End
  165.       Begin VB.Label Label1 
  166.          Caption         =   "Last Name"
  167.          Height          =   255
  168.          Index           =   1
  169.          Left            =   120
  170.          TabIndex        =   33
  171.          Top             =   1080
  172.          Width           =   975
  173.       End
  174.       Begin VB.Label Label1 
  175.          Caption         =   "SSN"
  176.          Height          =   255
  177.          Index           =   2
  178.          Left            =   120
  179.          TabIndex        =   32
  180.          Top             =   1440
  181.          Width           =   975
  182.       End
  183.    End
  184.    Begin VB.Data Data2 
  185.       Caption         =   "Data2"
  186.       Connect         =   "Access"
  187.       DatabaseName    =   "VB4OO.mdb"
  188.       Exclusive       =   0   'False
  189.       Height          =   300
  190.       Left            =   7920
  191.       Options         =   0
  192.       ReadOnly        =   -1  'True
  193.       RecordsetType   =   1  'Dynaset
  194.       RecordSource    =   "Addresses"
  195.       Top             =   1560
  196.       Visible         =   0   'False
  197.       Width           =   1140
  198.    End
  199.    Begin VB.Data Data1 
  200.       Caption         =   "Data1"
  201.       Connect         =   "Access"
  202.       DatabaseName    =   "VB4OO.mdb"
  203.       Exclusive       =   0   'False
  204.       Height          =   300
  205.       Left            =   7920
  206.       Options         =   0
  207.       ReadOnly        =   -1  'True
  208.       RecordsetType   =   1  'Dynaset
  209.       RecordSource    =   "Persons"
  210.       Top             =   1320
  211.       Visible         =   0   'False
  212.       Width           =   1140
  213.    End
  214.    Begin TabDlg.SSTab SSTab1 
  215.       Height          =   3135
  216.       Left            =   120
  217.       TabIndex        =   12
  218.       Top             =   2760
  219.       Width           =   8775
  220.       _Version        =   65536
  221.       _ExtentX        =   15478
  222.       _ExtentY        =   5530
  223.       _StockProps     =   15
  224.       Caption         =   "Addresses"
  225.       TabsPerRow      =   2
  226.       Tab             =   0
  227.       TabOrientation  =   0
  228.       Tabs            =   2
  229.       Style           =   1
  230.       TabMaxWidth     =   0
  231.       TabHeight       =   529
  232.       TabCaption(0)   =   "Addresses"
  233.       Tab(0).ControlCount=   7
  234.       Tab(0).ControlEnabled=   -1  'True
  235.       Tab(0).Control(0)=   "DBGrid2"
  236.       Tab(0).Control(1)=   "Label1(13)"
  237.       Tab(0).Control(2)=   "efFormattedAddress"
  238.       Tab(0).Control(3)=   "Frame2"
  239.       Tab(0).Control(4)=   "pbDeleteAddress"
  240.       Tab(0).Control(5)=   "pbUpdateAddress"
  241.       Tab(0).Control(6)=   "pbAddNewAddress"
  242.       TabCaption(1)   =   "Phones"
  243.       Tab(1).ControlCount=   7
  244.       Tab(1).ControlEnabled=   0   'False
  245.       Tab(1).Control(0)=   "DBGrid3"
  246.       Tab(1).Control(1)=   "Label1(21)"
  247.       Tab(1).Control(2)=   "efFormattedPhoneNumber"
  248.       Tab(1).Control(3)=   "Frame3"
  249.       Tab(1).Control(4)=   "pbDeletePhone"
  250.       Tab(1).Control(5)=   "pbUpdatePhone"
  251.       Tab(1).Control(6)=   "pbAddPhone"
  252.       Begin VB.CommandButton pbAddPhone 
  253.          Caption         =   "Add New"
  254.          Height          =   375
  255.          Left            =   -67320
  256.          TabIndex        =   28
  257.          Top             =   480
  258.          Width           =   975
  259.       End
  260.       Begin VB.CommandButton pbUpdatePhone 
  261.          Caption         =   "Update"
  262.          Height          =   375
  263.          Left            =   -67320
  264.          TabIndex        =   29
  265.          Top             =   960
  266.          Width           =   975
  267.       End
  268.       Begin VB.CommandButton pbDeletePhone 
  269.          Caption         =   "Delete"
  270.          Height          =   375
  271.          Left            =   -67320
  272.          TabIndex        =   30
  273.          Top             =   1440
  274.          Width           =   975
  275.       End
  276.       Begin VB.Frame Frame3 
  277.          Caption         =   "Address Details"
  278.          Height          =   2655
  279.          Left            =   -70680
  280.          TabIndex        =   50
  281.          Top             =   360
  282.          Width           =   3255
  283.          Begin VB.TextBox efUsage 
  284.             Height          =   285
  285.             Left            =   1200
  286.             TabIndex        =   27
  287.             Top             =   720
  288.             Width           =   1815
  289.          End
  290.          Begin VB.TextBox efPhoneNumber 
  291.             Height          =   285
  292.             Left            =   1200
  293.             TabIndex        =   26
  294.             Top             =   360
  295.             Width           =   1815
  296.          End
  297.          Begin VB.Label Label1 
  298.             Caption         =   "Usage"
  299.             Height          =   255
  300.             Index           =   16
  301.             Left            =   120
  302.             TabIndex        =   52
  303.             Top             =   720
  304.             Width           =   975
  305.          End
  306.          Begin VB.Label Label1 
  307.             Caption         =   "Phone Num"
  308.             Height          =   255
  309.             Index           =   15
  310.             Left            =   120
  311.             TabIndex        =   51
  312.             Top             =   360
  313.             Width           =   975
  314.          End
  315.       End
  316.       Begin VB.CommandButton pbAddNewAddress 
  317.          Caption         =   "Add New"
  318.          Height          =   375
  319.          Left            =   7680
  320.          TabIndex        =   22
  321.          Top             =   480
  322.          Width           =   975
  323.       End
  324.       Begin VB.CommandButton pbUpdateAddress 
  325.          Caption         =   "Update"
  326.          Height          =   375
  327.          Left            =   7680
  328.          TabIndex        =   23
  329.          Top             =   960
  330.          Width           =   975
  331.       End
  332.       Begin VB.CommandButton pbDeleteAddress 
  333.          Caption         =   "Delete"
  334.          Height          =   375
  335.          Left            =   7680
  336.          TabIndex        =   24
  337.          Top             =   1440
  338.          Width           =   975
  339.       End
  340.       Begin VB.Frame Frame2 
  341.          Caption         =   "Address Details"
  342.          Height          =   2655
  343.          Left            =   4320
  344.          TabIndex        =   39
  345.          Top             =   360
  346.          Width           =   3255
  347.          Begin VB.TextBox efLine1 
  348.             Height          =   285
  349.             Left            =   1200
  350.             TabIndex        =   14
  351.             Top             =   360
  352.             Width           =   1815
  353.          End
  354.          Begin VB.TextBox efLine2 
  355.             Height          =   285
  356.             Left            =   1200
  357.             TabIndex        =   15
  358.             Top             =   720
  359.             Width           =   1815
  360.          End
  361.          Begin VB.TextBox efLine3 
  362.             Height          =   285
  363.             Left            =   1200
  364.             TabIndex        =   16
  365.             Top             =   1080
  366.             Width           =   1815
  367.          End
  368.          Begin VB.TextBox efCity 
  369.             Height          =   285
  370.             Left            =   1200
  371.             TabIndex        =   17
  372.             Top             =   1440
  373.             Width           =   1815
  374.          End
  375.          Begin VB.TextBox efStateCode 
  376.             Height          =   285
  377.             Left            =   1200
  378.             MaxLength       =   2
  379.             TabIndex        =   18
  380.             Top             =   1800
  381.             Width           =   375
  382.          End
  383.          Begin VB.TextBox efZipCode 
  384.             Height          =   285
  385.             Left            =   1200
  386.             MaxLength       =   5
  387.             TabIndex        =   19
  388.             Top             =   2160
  389.             Width           =   735
  390.          End
  391.          Begin VB.TextBox efZipExtension 
  392.             Height          =   285
  393.             Left            =   2640
  394.             MaxLength       =   2
  395.             TabIndex        =   21
  396.             Top             =   2160
  397.             Width           =   375
  398.          End
  399.          Begin VB.TextBox efZipSupplement 
  400.             Height          =   285
  401.             Left            =   2040
  402.             MaxLength       =   4
  403.             TabIndex        =   20
  404.             Top             =   2160
  405.             Width           =   495
  406.          End
  407.          Begin VB.Label Label1 
  408.             Caption         =   "Line 1"
  409.             Height          =   255
  410.             Index           =   5
  411.             Left            =   120
  412.             TabIndex        =   45
  413.             Top             =   360
  414.             Width           =   975
  415.          End
  416.          Begin VB.Label Label1 
  417.             Caption         =   "Line 2"
  418.             Height          =   255
  419.             Index           =   6
  420.             Left            =   120
  421.             TabIndex        =   44
  422.             Top             =   720
  423.             Width           =   975
  424.          End
  425.          Begin VB.Label Label1 
  426.             Caption         =   "Line 3"
  427.             Height          =   255
  428.             Index           =   7
  429.             Left            =   120
  430.             TabIndex        =   43
  431.             Top             =   1080
  432.             Width           =   975
  433.          End
  434.          Begin VB.Label Label1 
  435.             Caption         =   "City"
  436.             Height          =   255
  437.             Index           =   10
  438.             Left            =   120
  439.             TabIndex        =   42
  440.             Top             =   1440
  441.             Width           =   975
  442.          End
  443.          Begin VB.Label Label1 
  444.             Caption         =   "State"
  445.             Height          =   255
  446.             Index           =   8
  447.             Left            =   120
  448.             TabIndex        =   41
  449.             Top             =   1800
  450.             Width           =   975
  451.          End
  452.          Begin VB.Label Label1 
  453.             Caption         =   "Zip Code"
  454.             Height          =   255
  455.             Index           =   9
  456.             Left            =   120
  457.             TabIndex        =   40
  458.             Top             =   2160
  459.             Width           =   975
  460.          End
  461.       End
  462.       Begin VB.Label efFormattedPhoneNumber 
  463.          BorderStyle     =   1  'Fixed Single
  464.          ForeColor       =   &H00FF0000&
  465.          Height          =   255
  466.          Left            =   -74880
  467.          TabIndex        =   54
  468.          Top             =   2760
  469.          Width           =   4095
  470.       End
  471.       Begin VB.Label Label1 
  472.          Caption         =   "Formatted Phone"
  473.          Height          =   255
  474.          Index           =   21
  475.          Left            =   -74880
  476.          TabIndex        =   53
  477.          Top             =   2520
  478.          Width           =   1575
  479.       End
  480.       Begin MSDBGrid.DBGrid DBGrid3 
  481.          Bindings        =   "CustDtls.frx":0000
  482.          Height          =   1935
  483.          Left            =   -74880
  484.          OleObjectBlob   =   "CustDtls.frx":000E
  485.          TabIndex        =   25
  486.          Top             =   480
  487.          Width           =   4095
  488.       End
  489.       Begin VB.Label efFormattedAddress 
  490.          BorderStyle     =   1  'Fixed Single
  491.          ForeColor       =   &H00FF0000&
  492.          Height          =   975
  493.          Left            =   120
  494.          TabIndex        =   47
  495.          Top             =   2040
  496.          Width           =   4095
  497.       End
  498.       Begin VB.Label Label1 
  499.          Caption         =   "Formatted Address"
  500.          Height          =   255
  501.          Index           =   13
  502.          Left            =   120
  503.          TabIndex        =   46
  504.          Top             =   1800
  505.          Width           =   1575
  506.       End
  507.       Begin MSDBGrid.DBGrid DBGrid2 
  508.          Bindings        =   "CustDtls.frx":08E2
  509.          Height          =   1215
  510.          Left            =   120
  511.          OleObjectBlob   =   "CustDtls.frx":08F0
  512.          TabIndex        =   13
  513.          Top             =   480
  514.          Width           =   4095
  515.       End
  516.    End
  517.    Begin VB.Label Label1 
  518.       Caption         =   "Formatted Name"
  519.       Height          =   255
  520.       Index           =   14
  521.       Left            =   120
  522.       TabIndex        =   49
  523.       Top             =   2160
  524.       Width           =   1575
  525.    End
  526.    Begin VB.Label efFormattedName 
  527.       BorderStyle     =   1  'Fixed Single
  528.       ForeColor       =   &H00FF0000&
  529.       Height          =   255
  530.       Left            =   120
  531.       TabIndex        =   48
  532.       Top             =   2400
  533.       Width           =   4215
  534.    End
  535.    Begin MSDBGrid.DBGrid DBGrid1 
  536.       Bindings        =   "CustDtls.frx":0FF8
  537.       Height          =   1935
  538.       Left            =   120
  539.       OleObjectBlob   =   "CustDtls.frx":1006
  540.       TabIndex        =   0
  541.       Top             =   120
  542.       Width           =   4215
  543.    End
  544. Attribute VB_Name = "CustomersAndAddresses"
  545. Attribute VB_Creatable = False
  546. Attribute VB_Exposed = False
  547. Option Explicit
  548. Private pvtCurrentPerson As Person
  549. Private pvtCurrentAddress As Address
  550. Private pvtCurrentPhone As Phone
  551. Private Sub Data2_Reposition()
  552.     On Local Error Resume Next
  553.     Me.MousePointer = vbArrowHourglass
  554. ' map the selected Address to an Address in the
  555. '   Person.Addresses collection
  556.     Set pvtCurrentAddress = _
  557.         pvtCurrentPerson _
  558.             .Addresses _
  559.             (CStr(Data2.RecordSet("ObjectID")))
  560.     If pvtCurrentAddress Is Nothing Or Err = 3021 Then
  561.         efLine1 = ""
  562.         efLine2 = ""
  563.         efLine3 = ""
  564.         efCity = ""
  565.         efStateCode = ""
  566.         efZipCode = ""
  567.         efZipSupplement = ""
  568.         efZipExtension = ""
  569.         efFormattedAddress = ""
  570.         Me.MousePointer = vbArrow
  571.         Exit Sub
  572.     End If
  573.     efLine1 = pvtCurrentAddress.Line1
  574.     efLine2 = pvtCurrentAddress.Line2
  575.     efLine3 = pvtCurrentAddress.Line3
  576.     efCity = pvtCurrentAddress.City
  577.     efStateCode = pvtCurrentAddress.StateCode
  578.     efZipCode = pvtCurrentAddress.ZipCode
  579.     efZipSupplement = pvtCurrentAddress.ZipSupplement
  580.     efZipExtension = pvtCurrentAddress.ZipExtension
  581.     efFormattedAddress = pvtCurrentAddress.FormattedAddress
  582.     Me.MousePointer = vbArrow
  583. End Sub
  584. Private Sub Data3_Reposition()
  585.     On Local Error Resume Next
  586.     Me.MousePointer = vbArrowHourglass
  587. ' map the selected Phone to a Phone in the
  588. '   Person.Phones collection
  589.     Set pvtCurrentPhone = _
  590.         pvtCurrentPerson _
  591.             .Phones _
  592.             (CStr(Data3.RecordSet("ObjectID")))
  593.     If pvtCurrentPhone Is Nothing Or Err = 3021 Then
  594.         efPhoneNumber = ""
  595.         efUsage = ""
  596.         efFormattedPhoneNumber = ""
  597.         Me.MousePointer = vbArrow
  598.         Exit Sub
  599.     End If
  600.     efPhoneNumber = pvtCurrentPhone.PhoneNumber
  601.     efUsage = pvtCurrentPhone.Usage
  602.     efFormattedPhoneNumber = pvtCurrentPhone.FormattedPhoneNumber
  603.     Me.MousePointer = vbArrow
  604. End Sub
  605. Private Sub pbAddNewAddress_Click()
  606.     Dim tempNewAddress As New Address
  607.         
  608.     On Local Error Resume Next
  609.     Me.MousePointer = vbArrowHourglass
  610.     With tempNewAddress
  611.         .Line1 = efLine1
  612.         .Line2 = efLine2
  613.         .Line3 = efLine3
  614.         .City = efCity
  615.         .StateCode = efStateCode
  616.         .ZipCode = efZipCode
  617.         .ZipSupplement = efZipSupplement
  618.         .ZipExtension = efZipExtension
  619.     End With
  620.             
  621.     pvtCurrentPerson.AddAddress _
  622.         Item:=tempNewAddress
  623.         
  624.     Set Data2.RecordSet = pvtCurrentPerson.Addresses.RecordSet
  625.     Data2.RecordSet.MoveFirst
  626.     Me.MousePointer = vbArrow
  627. End Sub
  628. Private Sub pbAddNewCustomer_Click()
  629.     Dim tempNewPerson As New Person
  630.         
  631.     On Local Error Resume Next
  632.     Me.MousePointer = vbArrowHourglass
  633.     With tempNewPerson
  634.         .CustomerNumber = efCustomerNumber
  635.         .FirstName = efFirstName
  636.         .LastName = efLastName
  637.         .SSN = efSSN
  638.         .Sex = efSex
  639.         .MaritalStatus = efMaritalStatus
  640.         .DateOfBirth = efDateOfBirth
  641.     End With
  642.         
  643.     publicCompany.AddPerson _
  644.         Item:=tempNewPerson
  645.         
  646.     Data2.Enabled = False
  647.     Data3.Enabled = False
  648.     Set Data1.RecordSet = publicCompany.Persons.RecordSet
  649.     Data1.RecordSet.FindFirst "ObjectID = " & CStr(tempNewPerson.ObjectID)
  650.     Me.MousePointer = vbArrow
  651. End Sub
  652. Private Sub pbAddPhone_Click()
  653.     Dim tempNewPhone As New Phone
  654.         
  655.     On Local Error Resume Next
  656.     Me.MousePointer = vbArrowHourglass
  657.     With tempNewPhone
  658.         .PhoneNumber = efPhoneNumber
  659.         .Usage = efUsage
  660.     End With
  661.             
  662.     pvtCurrentPerson.AddPhone _
  663.         Item:=tempNewPhone
  664.     Set Data3.RecordSet = pvtCurrentPerson.Phones.RecordSet
  665.     Data3.RecordSet.MoveFirst
  666.     Me.MousePointer = vbArrow
  667. End Sub
  668. Private Sub pbDeleteAddress_Click()
  669.     On Local Error Resume Next
  670.     Me.MousePointer = vbArrowHourglass
  671.     Set pvtCurrentAddress = _
  672.         pvtCurrentPerson _
  673.             .Addresses _
  674.             (CStr(Data2.RecordSet("ObjectID")))
  675.            
  676.     pvtCurrentPerson.Addresses.Remove _
  677.         Item:=pvtCurrentAddress
  678.         
  679.     Set Data2.RecordSet = pvtCurrentPerson.Addresses.RecordSet
  680.     Data2.RecordSet.MoveFirst
  681.     Me.MousePointer = vbArrow
  682. End Sub
  683. Private Sub pbDeleteCustomer_Click()
  684.     Dim saveObjectID As String
  685.     On Local Error Resume Next
  686.     Me.MousePointer = vbArrowHourglass
  687.     Set pvtCurrentPerson = _
  688.         publicCompany _
  689.             .Persons _
  690.             (CStr(Data1.RecordSet("ObjectID")))
  691.     publicCompany.Persons.Remove _
  692.         Item:=pvtCurrentPerson
  693.         
  694.     Set Data1.RecordSet = publicCompany.Persons.RecordSet
  695.     Data1.RecordSet.MoveFirst
  696.     Me.MousePointer = vbArrow
  697. End Sub
  698. Private Sub pbDeletePhone_Click()
  699.     Dim saveObjectID As String
  700.     On Local Error Resume Next
  701.     Me.MousePointer = vbArrowHourglass
  702.     saveObjectID = CStr(pvtCurrentPhone.ObjectID)
  703.     With pvtCurrentPhone
  704.         .PhoneNumber = efPhoneNumber
  705.         .Usage = efUsage
  706.     End With
  707.     pvtCurrentPerson.Phones.Remove _
  708.         Item:=pvtCurrentPhone
  709.         
  710.     Set Data3.RecordSet = pvtCurrentPerson.Phones.RecordSet
  711.     Data3.RecordSet.MoveFirst
  712.     Me.MousePointer = vbArrow
  713. End Sub
  714. Private Sub pbOK_Click()
  715.     End
  716. End Sub
  717. Private Sub Data1_Reposition()
  718.         
  719.     On Local Error Resume Next
  720.     Me.MousePointer = vbArrowHourglass
  721.     Data2.Enabled = True
  722.     Data3.Enabled = True
  723.         
  724. ' set the CurrentPerson object to correspond to
  725. '   Person selected in the DBGrid
  726. '   Company.Persons collection
  727.     Set pvtCurrentPerson = _
  728.         publicCompany _
  729.             .Persons _
  730.             (CStr(Data1.RecordSet("ObjectID")))
  731.     If pvtCurrentPerson Is Nothing Then
  732.         Data2.Enabled = False
  733.         Data3.Enabled = False
  734.         Me.MousePointer = vbArrow
  735.         Exit Sub
  736.     End If
  737.         
  738. ' display the person's detail information
  739.     efCustomerNumber = pvtCurrentPerson.CustomerNumber
  740.     efFirstName = pvtCurrentPerson.FirstName
  741.     efLastName = pvtCurrentPerson.LastName
  742.     efSSN = pvtCurrentPerson.SSN
  743.     efDateOfBirth = Format$(pvtCurrentPerson.DateOfBirth, "mm/dd/yyyy")
  744.     efMaritalStatus = pvtCurrentPerson.MaritalStatus
  745.     efSex = pvtCurrentPerson.Sex
  746.     efFormattedName = pvtCurrentPerson.FormattedName
  747. ' display details of the first Address
  748.     pvtCurrentPerson.Addresses.RecordSet.MoveFirst
  749. ' reset the Person.Addresses RecordSet
  750. '   (to bring to current the contents of the DBGrid)
  751.     Set Data2.RecordSet = _
  752.         pvtCurrentPerson.Addresses.RecordSet
  753. ' display details of the first Phone
  754.     pvtCurrentPerson.Phones.RecordSet.MoveFirst
  755. ' reset the Person.Phones RecordSet
  756. '   (to bring to current the contents of the DBGrid)
  757.     Set Data3.RecordSet = _
  758.         pvtCurrentPerson.Phones.RecordSet
  759.     Me.MousePointer = vbArrow
  760. End Sub
  761. Private Sub DBGrid2_AfterInsert()
  762.     Dim NewAddress As New Address
  763.     Set NewAddress = _
  764.         pvtCurrentPerson.Addresses.Add( _
  765.             Line1:=Data2.RecordSet("Line1"), Line2:=Data2.RecordSet("Line2"), Line3:=Data2.RecordSet("Line3"), _
  766.             City:=Data2.RecordSet("City"), StateCode:=Data2.RecordSet("StateCode"), _
  767.             ZipCode:=Data2.RecordSet("ZipCode"), ZipSupplement:=Data2.RecordSet("ZipSupplement"), ZipExtension:=Data2.RecordSet("ZipExtension"), _
  768.             Status:="Current", Usage:="Residence", _
  769.             LinkTo:=pvtCurrentPerson)
  770. End Sub
  771. Private Sub Form_Load()
  772.     Data2.Enabled = False
  773.     Data3.Enabled = False
  774.     Set Data1.RecordSet = _
  775.         publicCompany.Persons.RecordSet
  776.     Data1.RecordSet.MoveFirst
  777. End Sub
  778. Private Sub pbUpdateAddress_Click()
  779. ' update the person's detail information
  780.     Dim saveObjectID As String
  781.         
  782.     On Local Error Resume Next
  783.     Me.MousePointer = vbArrowHourglass
  784.     saveObjectID = CStr(pvtCurrentAddress.ObjectID)
  785.     With pvtCurrentAddress
  786.         .Line1 = efLine1
  787.         .Line2 = efLine2
  788.         .Line3 = efLine3
  789.         .City = efCity
  790.         .StateCode = efStateCode
  791.         .ZipCode = efZipCode
  792.         .ZipSupplement = efZipSupplement
  793.         .ZipExtension = efZipExtension
  794.     End With
  795.     pvtCurrentPerson.Addresses.Replace _
  796.         Item:=pvtCurrentAddress, _
  797.         ReplaceWith:=pvtCurrentAddress
  798.         
  799.     Set Data2.RecordSet = pvtCurrentPerson.Addresses.RecordSet
  800.     Data2.RecordSet.FindFirst "ObjectID = " & saveObjectID
  801.     Me.MousePointer = vbArrow
  802. End Sub
  803. Private Sub pbUpdateCustomer_Click()
  804. ' update the person's detail information
  805.     Dim saveObjectID As String
  806.         
  807.     On Local Error Resume Next
  808.     Me.MousePointer = vbArrowHourglass
  809.     saveObjectID = CStr(pvtCurrentPerson.ObjectID)
  810.     With pvtCurrentPerson
  811.         .CustomerNumber = efCustomerNumber
  812.         .FirstName = efFirstName
  813.         .LastName = efLastName
  814.         .SSN = efSSN
  815.         .DateOfBirth = efDateOfBirth
  816.         .MaritalStatus = efMaritalStatus
  817.         .Sex = efSex
  818.     End With
  819.     publicCompany.Persons.Replace _
  820.         Item:=CStr(pvtCurrentPerson.ObjectID), _
  821.         ReplaceWith:=pvtCurrentPerson
  822.         
  823.     Set Data1.RecordSet = publicCompany.Persons.RecordSet
  824.     Data1.RecordSet.FindFirst "ObjectID = " & saveObjectID
  825.     Me.MousePointer = vbArrow
  826. End Sub
  827. Private Sub pbUpdatePhone_Click()
  828. ' update the person's Phone information
  829.     Dim saveObjectID As String
  830.         
  831.     On Local Error Resume Next
  832.     Me.MousePointer = vbArrowHourglass
  833.     saveObjectID = CStr(pvtCurrentPhone.ObjectID)
  834.     With pvtCurrentPhone
  835.         .PhoneNumber = efPhoneNumber
  836.         .Usage = efUsage
  837.     End With
  838.             
  839.     pvtCurrentPerson.Phones.Replace _
  840.         Item:=pvtCurrentPhone, _
  841.         ReplaceWith:=pvtCurrentPhone
  842.     Set Data3.RecordSet = pvtCurrentPerson.Phones.RecordSet
  843.     Data3.RecordSet.MoveFirst
  844.     Me.MousePointer = vbArrow
  845. End Sub
  846.