ACC2000: Year Calendar Report

accessGod

New member
Local time
Today, 00:05
Joined
Jul 6, 2008
Messages
4
How to invoke the call function in code? Pls provide the code?

Code:
Function getCalendarData(employeeID As Long) As Boolean

Dim rs As DAO.Recordset
Dim strDate As String
Dim strCode As String
Dim strSQL As String
Dim i As Integer
    '//Set rs = CurrentDb.OpenRecordset("t_employeeAttendance", dbOpenDynaset)
    strSQL = "SELECT * From t_employeeAttendance WHERE employeeID = " & employeeID
    Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
    Set colCalendarDates = New Collection
    With rs
        '//If (Not .BOF) Or (Not .EOF) Then
        '//  .MoveLast
        '//  .MoveFirst
        '//End If
        If .RecordCount > 0 Then
          .MoveLast
          .MoveFirst
            
            For i = 1 To .RecordCount
                strDate = .Fields("attendanceDate")
                strCode = .Fields("statusCode")
                colCalendarDates.Add strCode, strDate
                .MoveNext
            Next i
        End If
        .Close
    End With
    '// return date collection
    Set rs = Nothing
End Function
 
I assume you're asking how to call the function you pasted?

If so:
Code:
If getCalendarData (aVariableHoldingAnEmployeeOrALiteral) then
DoSomething
Else
DoSomethingElse
End If

Though I'm not sure why you'd want to call that function since it doesn't really do anything but take up CPU cycles, unless there is some global being set. This code breaks many rules.
 
Error occurs at the call getCalendarData from the sample of Year Calendar Report. Wanted to display each empID record when report is shown but can only show 1 record for all diff. empID thus modified the code as below to
Code:
Public Sub loadReportYearCalendar(theReport As Report)
Dim i As Integer
Dim datStart As Date
Dim rptControl As Report
    
    m_strCTLLabel = "labelCELL"
    m_strCTLLabelHeader = "labelDAY"
    
    '// load dates into our collection
    Call getCalendarData

    With theReport
        '// get the first month of the year
        datStart = "1/1/" & Year(Date)
        '// add the year to the report's label
        .Controls("labelCalendarHeaderLine2").Caption = Year(datStart) & " iCalendar"
        For i = 1 To 12
            '// set pointer to subreport control hosting the mini-calendar
            Set rptControl = .Controls("childCalendarMonth" & i).Report
            '// run procedure to populate control with it's respective year
            Call loadReportCalendar(rptControl, datStart)
            '// reset and obtain first day of the following month
            datStart = DateAdd("m", 1, datStart)
        Next i
    End With
    '// clean up
    Set colCalendarDates = Nothing
    Set rptControl = Nothing
End Sub
 
I means how to load dates into collection as shown above so that it'll display each empID records?
 
"AccessGod"?!

Total of four posts, all asking questions, none providing answers.

Does your mommy & daddy know you're loose on the Internet?

Grow up!
 
Last edited:
Ooooo. I thought I had to be polite. But now that you mention it...

AG, if you ever attain that status, I'll be right there rooting for you.

For now, though, what do you want? Your first post didn't ask a concrete question and displayed some poorly written code. Your second post shows some totally different code that I didn't even really evaluate and says you have an error, presumably incorrectly calling the first set of code. Why didn't you send an employee ID to the function? It won't work without that (if at all).
 

Users who are viewing this thread

Back
Top Bottom