'====================================== ' Class: clsOrder '====================================== '************************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 = "tblOrders" Private mlOrderID As Long Public CustomerID As Long Public Item As String Public Qty As Long Public UnitPrice As Currency '--------------------------------------------- Property Get OrderID() As Long ' Read only OrderID = mlOrderID End Property '--------------------------------------------- Public Function Create() As Boolean '--------------------------------------------- ' Save to the database tables (New document for first time) On Error GoTo HandleError Create = False Dim rs As DAO.Recordset Set rs = CurrentDb().OpenRecordset(scTABLE, dbOpenDynaset) With rs .AddNew !CustomerID = Me.CustomerID !Item = Me.Item !Qty = Me.Qty !UnitPrice = Me.UnitPrice .Update .Bookmark = .LastModified mlOrderID = !OrderID ' Get ID from new record .Close End With Set rs = Nothing Create = True Done: Exit Function HandleError: MsgBox "Error " & Err.Number & " in Create" & vbCr & Err.Description, vbCritical Resume Done End Function