home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1997 May / pcpro0597.iso / code / Appcode.txt
Encoding:
Text File  |  1997-03-03  |  1.3 KB  |  49 lines

  1. Listing One
  2. Option Explicit
  3.  
  4. Private dbPiAccounts As Database
  5. Private rsPiCustomer As Recordset
  6.  
  7. Private Sub txtCustomer_Enter()
  8.     cmdSearch.Default = True
  9. End Sub
  10.  
  11. Private Sub UserForm_Initialize()
  12.     Set dbPiAccounts = DBEngine.OpenDatabase("d:\my documents\accounts 97.mdb", False, True)
  13. End Sub
  14.  
  15. Private Sub cmdSearch_Click()
  16.     Set rsPiCustomer = dbPiAccounts.OpenRecordset("SELECT * FROM customers WHERE name LIKE '" & txtCustomer & "*'", dbOpenSnapshot)
  17.     
  18.     If rsPiCustomer.EOF Then
  19.         txtAddress = ""
  20.         txtCustomer.SetFocus
  21.     Else
  22.         txtAddress = rsPiCustomer!Name & vbCrLf & _
  23.                      rsPiCustomer!address1 & vbCrLf & _
  24.                      rsPiCustomer!address2 & vbCrLf & _
  25.                      rsPiCustomer!address3 & vbCrLf & _
  26.                      rsPiCustomer!address4 & vbCrLf & _
  27.                      rsPiCustomer!postcode
  28.                  
  29.         If chkInclude Then
  30.             txtAddress = txtAddress & vbCrLf & rsPiCustomer!phonenumber
  31.         End If
  32.     
  33.         cmdPaste.Default = True
  34.     End If
  35.     
  36.     rsPiCustomer.Close
  37. End Sub
  38.  
  39. Private Sub cmdPaste_Click()
  40.     Selection.InsertAfter (txtAddress)
  41.     Me.Hide
  42. End Sub
  43.  
  44. Listing Two
  45. Public Sub CustomerAddress()
  46.     frmCustomerAddress.Show
  47. End Sub 
  48.  
  49.