SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 151 | Next

Jim DeMarco

"Pro Excel 2007 VBA"


If m_xlWksht Is Nothing Then 'double check that we still have a valid object
blnReturn = False
GoTo Exit_Function
End If
If it doesn??™t, we return a False value and exit the function.
Next we get our empty row location from our cExcelUtils object:
lngNewRowNum = m_oXL.FindEmptyRow(m_xlWksht)
Then we use the m_xlWksht variable that contains the database worksheet and populate
each column in the row with data from our class properties:
With m_xlWksht
.Cells(lngNewRowNum, 1).Value = Me.ID
.Cells(lngNewRowNum, 2).Value = Me.State
.Cells(lngNewRowNum, 3).Value = Me.PhoneNumber
.Cells(lngNewRowNum, 4).Value = Me.HeardOfProduct
.Cells(lngNewRowNum, 5).Value = Me.WantsProduct
.Cells(lngNewRowNum, 6).Value = Me.Followup
End With
Finally, we check that we have not received any errors, set the success flag to True, and
then exit the function:
If Err.Number = 0 Then
blnReturn = True
End If
Exit_Function:
Save = blnReturn
Exit Function
That??™s it for the cCustSurvey class.We??™ve just built a class to hold our input values from the
UserForm. It will find the next ID value for any new records and it will save the data to the
worksheet we pass into the class in the next free row.
Coding the UserForm
We just created a class to handle our data and modified our Excel Utility class to help the
cCustSurvey class. Let??™s put cCustSurvey to work by coding it into our UserForm.
Open the Customer Survey form (UserForm1). Open the code view by clicking the View
Code button on the Project Explorer toolbar, as shown in Figure 4-7.


Pages:
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163