Prev | Current Page 1996 | Next

Michael R. Groh, Joseph C. Stockman, Gavin Powell, and Cary N. Prague

"Access 2007 Bible"

For instance, consider a data management object that reads and writes data from a data
source. The properties are easy to understand and may include the path to the data source, the
name of a table, and an ID value to use when extracting or saving data.
In this case, you may add an event to the data management object that is triggered when the data
source is unavailable, or when a record matching the ID value cannot be found. Using events is
much cleaner and more direct than relying on errors to be thrown when the data management
object fails to complete its task.
The need for events
To my knowledge, there is no limit on the number of events you can add to a class module. You
declare events in a class module??™s header, and invoke the events within the class??™s properties and
methods.
This process may make more sense if we consider a property procedure built earlier in this chapter:
Public Property Get SupplierName() As String
Dim varTemp As Variant
If m_SupplierID <= 0 Then
Exit Property
End If
varTemp = DLookup(???CompanyName???, ???Suppliers???, _
???SupplierID = ??? & m_SupplierID)
1068
Professional Database Development Part IV
If Not IsNull(varTemp) Then
SupplierName = CStr(varTemp)
End If
End Property
This property procedure returns the name of a product supplier, given the SupplierID (notice
that the SupplierID is obtained through the class-level m_SupplierID variable).


Pages:
1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008
instalacje elektryczne Stemple Datowniki fotograf ślubny Avier 2