LittleSmudge
Programmer
I have recently been updating a database I developed just over a year ago.
In BOTH there is the following sub:-
In the original version this code works fine.
But all of a sudden in the latest version I get the
"Error 3464 Data type mismatch in criteria expression"
error.
If I take the SQL string and put it in a query of its own it fails too.
By experimentation I have determined that it is the WHERE caluse
WHERE (((DateAdd('yyyy',19,[DoB])) > DateSerial(Year([EnrolmentDate]),8,31)))
that it is objecting too.
What's more, something very strange happens in a query.
When I go to look at the data it first displays the data, then the message box appears with the error message in it.
When I lick on the Okay button all of the fields in all of the records turn to "#Name?"
BUT it still shows #Name? for the right number of records that the WHERE clause should select.
So the Where clause is doing the right calculation despite the error message.
What's going on ?
PS. the Where clause selects records where learner was <19 years old on 31August in year of course enrolment
G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
In BOTH there is the following sub:-
Code:
Private Sub ViewYoungsters()
Dim strSQL As String
Dim cqd As clsQueryDefs
Set cqd = New clsQueryDefs
strSQL = "SELECT CName, CRef, LastName, FirstName, UserName, DoB, " _
& "CourseRef, SUId, EnrolmentDate, ContactMethod " _
& "FROM tblC " _
& "INNER JOIN (tblPerson " _
& "INNER JOIN tblPersonCourse " _
& "ON tblPerson.PersonId = tblPersonCourse.PersonRef) " _
& "ON tblC.CId = tblPersonCourse.CRef " _
& "WHERE (((DateAdd('yyyy',19,[DoB])) > DateSerial(Year([EnrolmentDate]),8,31))) "
If Len(Nz(cboCYL, "")) > 0 Then
strSQL = strSQL & "AND CRef = '" & cboCYL & "' "
End If
strSQL = strSQL & "ORDER BY CRef, LastName, FirstName, DoB "
Call cqd.Reports(strSQL)
Set cqd = Nothing
DoCmd.OpenReport "rptYoungsters", acViewPreview
End Sub
In the original version this code works fine.
But all of a sudden in the latest version I get the
"Error 3464 Data type mismatch in criteria expression"
error.
If I take the SQL string and put it in a query of its own it fails too.
By experimentation I have determined that it is the WHERE caluse
WHERE (((DateAdd('yyyy',19,[DoB])) > DateSerial(Year([EnrolmentDate]),8,31)))
that it is objecting too.
What's more, something very strange happens in a query.
When I go to look at the data it first displays the data, then the message box appears with the error message in it.
When I lick on the Okay button all of the fields in all of the records turn to "#Name?"
BUT it still shows #Name? for the right number of records that the WHERE clause should select.
So the Where clause is doing the right calculation despite the error message.
What's going on ?
PS. the Where clause selects records where learner was <19 years old on 31August in year of course enrolment
G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.