14.5. Building the Standard Modules
Now that you have created the properties and methods for the Customer objects, you are ready to begin writing the code in the standard modules.
|
The modBusinessLogic module will contain business logic but will not contain any database access calls. The modDatabaseLogic module will contain calls that are specific to the database. Let's create these modules.
Insert a new standard module called modBusinessLogic. Add the following code to the General Declarations of the module: Option Compare Database
Option Explicit
Const BUS_LOGIC = "modBusinessLogic"
Public intCustomerLookupId As Integer
Add the following FixNull function to the modBusinessLogic module: Function FixNull(varIn As Variant) As String
'this procedure sets null values in the recordset
'to a null string so an error does not occur when
'trying to assign the value to a control for display
'if the value is null
If IsNull(varIn) Then
FixNull = ""
Else
'return the value passed in
FixNull = varIn
End If
End Function
Add the following PopulateListFromRecordset procedure to the modBusinessLogic module: Sub PopulateListFromRecordset(lstList As ListBox, rsRecordset As _ ADODB.Recordset, intNumCols As Integer) On Error GoTo HandleError Dim intCounter As Integer Dim strItem As String With lstList .RowSource = "" .ColumnCount = intNumCols .RowSourceType = "Value List" End With 'add all of the values in the recordset to the list ...
|