'====================================== ' Class: clsCustomer '====================================== '************************COPYRIGHT NOTICE************************* ' Copyright (C) 2000 DI Management Services Pty Ltd, ' Sydney Australia www.di-mgt.com.au. All rights reserved. ' This code was originally written by David Ireland. ' You are free to use it in any application ' provided this copyright notice is left intact. ' If you use it, or found it useful, or can suggest an improvement ' please let us know at code@di-mgt.com.au. '***************************************************************** Option Compare Database Option Explicit Private Const scTABLE As String = "tblCustomers" Private mlCustomerID As Long Public CustomerName As String Public Address As String Public Telephone As String Public DiscountRate As Double Public Terms As Long '--------------------------------------------- Property Get CustomerID() As Long ' Read only CustomerID = mlCustomerID End Property '------------------------------------------- Public Function Load(ID As Long) As Boolean '------------------------------------------- On Error GoTo HandleError Dim rs As DAO.Recordset Dim sQry As String Load = False sQry = "SELECT * FROM " & scTABLE & " WHERE ([CustomerID]=" & ID & ");" Set rs = CurrentDb().OpenRecordset(sQry, dbOpenForwardOnly) With rs If .RecordCount = 0 Then MsgBox "Cannot find Customer with ID = " & ID, vbCritical GoTo Done End If mlCustomerID = !CustomerID Me.CustomerName = !CustomerName Me.Address = !Address Me.Telephone = !Telephone Me.DiscountRate = !DiscountRate Me.Terms = !Terms .Close End With Set rs = Nothing Load = True Done: Exit Function HandleError: MsgBox "Error loading Customer: " & vbCrLf & Err.Description, vbCritical Resume Done End Function