L
Larry Salvucci
I'm having a problem getting this code to work. I keep getting a data type
mismatch error. What I'm trying to do is create a strSQL to only select
records that equal the employeeID. Where am I going wrong?
Function getCalendarData() As Boolean
Dim rs As DAO.Recordset
Dim strDate As String
Dim strCode As String
Dim i As Integer
Dim strSQL As String
Dim strEmployee As String
strEmployee = [Forms]![frmEmployeeMain]![ID]
strSQL = "SELECT t_employeeAttendance.*, t_employeeAttendance.employeeID
FROM t_employeeAttendance WHERE t_employeeAttendance.employeeID = " &
strEmployee & ";"
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
Set colCalendarDates = New Collection
With rs
If (Not .BOF) Or (Not .EOF) Then
.MoveLast
.MoveFirst
End If
If .RecordCount > 0 Then
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
mismatch error. What I'm trying to do is create a strSQL to only select
records that equal the employeeID. Where am I going wrong?
Function getCalendarData() As Boolean
Dim rs As DAO.Recordset
Dim strDate As String
Dim strCode As String
Dim i As Integer
Dim strSQL As String
Dim strEmployee As String
strEmployee = [Forms]![frmEmployeeMain]![ID]
strSQL = "SELECT t_employeeAttendance.*, t_employeeAttendance.employeeID
FROM t_employeeAttendance WHERE t_employeeAttendance.employeeID = " &
strEmployee & ";"
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
Set colCalendarDates = New Collection
With rs
If (Not .BOF) Or (Not .EOF) Then
.MoveLast
.MoveFirst
End If
If .RecordCount > 0 Then
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