Access.2007.VBA.Bibl..

(John Hannent) #1

Count the number of records for this employee:


.MoveLast
.MoveFirst
lngCount = .RecordCount

Create a new workbook from the template to enter hours:


Set wkb = appExcel.Workbooks.Add(strTemplateFile)
Set wks = wkb.Sheets(1)
wks.Activate
appExcel.Visible = True
wks.Range(“C3”) = ![EmployeeName]
wks.Range(“C4”) = ![ManagerName]
wks.Range(“F3”) = Nz(![HomePhone])
wks.Range(“F4”) = Nz(![Email])
wks.Range(“C6”) = ![WeekEnding]

For n = 1 To lngCount
Debug.Print “Record “ & n & “ for “ _
& strEmployeeName

If n = 1 Then

Process hours for first project.


Check for hours worked on Monday:


If Nz(![MondayHours]) _
+ Nz(![MondayOTHours]) > 0 Then
appExcel.GoTo _
Reference:=wks.Range(“Monday”)
Set rngCC = _
appExcel.ActiveCell.Offset(columnoffset:=2)
Set rngPC = _
appExcel.ActiveCell.Offset(columnoffset:=3)
Set rngRH = _
appExcel.ActiveCell.Offset(columnoffset:=4)
Set rngOT = _
appExcel.ActiveCell.Offset(columnoffset:=5)
rngCC.Value = ![ClientCode]
rngPC.Value = ![ProjectCode]
rngRH.Value = ![MondayHours]
rngOT.Value = ![MondayOTHours]
End If

[Similar code for processing Tuesday through Sunday hours omitted.]


ElseIf n > 1 Then

Working with Excel Worksheets 7

Free download pdf