FindEmptyRow(m_oWorksheet)
Set m_oEmployee = Employee
SaveEmpData
SaveAddressData
SaveEquipmentData
SaveAccessData
Exit_Function:
SaveEmployee = blnReturn
Exit Function
End Function
Add the following class initialization and cleanup code:
Private Sub Class_Initialize()
Set m_oXL = New cExcelUtils
End Sub
Private Sub Class_Terminate()
Set m_oXL = Nothing
End Sub
The Worksheet property lets us define where the data will be stored in our workbook. The
SaveEmployee method does a few things for us when we pass in a cPerson object:
Public Function SaveEmployee(Employee As cPerson) As Boolean
It checks to see that the Worksheet property has been set so we know where to save our
data:
If m_oWorksheet Is Nothing Then
GoTo Exit_Function
End If
It finds the first empty row using the cExcelUtils object:
m_lngNewRowNum = m_oXL.FindEmptyRow(m_oWorksheet)
Then we assign the cPerson object we passed in to the method to a private module-level
cPerson object that will be used in various save functions:
Set m_oEmployee = Employee
CHAPTER 4 n USERFORMS 170
Lastly, it fires a few save functions, one for each data object:
SaveEmpData
SaveAddressData
SaveEquipmentData
SaveAccessData
The Save methods simply transfer the data values stored in the cPerson object (and its
internal data objects) to a cell on the EmpData worksheet. Add the following Save methods
to the cHRData class module:
Private Sub SaveEmpData()
With m_oWorksheet
.Cells(m_lngNewRowNum, 1).
Pages:
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179