thunderain
Programmer
Im my program I am doing several searches on the database. I have a
problem with dates. My first search to equal a date gives no error. Works
fine. A second search to find a date inside a range gives a data type
mismatch error. I don't know why I would get this here when the equals
seach does not give this error. It seems that using anything other then "Like" gives data mismatch when dealing with dates. My inside range and all other searchs work with anything other then dates.
ERROR MESSAGE:
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria
expression.
EQUALS SEARCH CODE (this works fine):
If Request.Form("OccEntryDate"
<> "" AND Request.Form("ChoiceOccEntryDate"
= "equals" Then
occValue = Request.Form ("OccEntryDate"
Set objRS3 = objCon.Execute("SELECT * FROM tblView WHERE SubcategoryID=1 AND FieldType='date'"
fieldname = objRS3("FieldName"
Set objRS1 = objCon.Execute("SELECT SelectClause, viewID FROM tblSubCategory WHERE SubCategoryID=1"
strSQL = objRS1("SelectClause"
& " AND (" & fieldname & " Like'" & occValue & "') ORDER BY " & fieldname
objRS1.Close
End If
INSIDE RANGE CODE (gives error above):
If Request.Form("OccEntryDate"
<> "" AND Request.Form("OccEntryDate2"
<> "" AND Request.Form("ChoiceOccEntryDate"
= "insiderange" Then
occValue = Request.Form ("OccEntryDate"
occValue2 = Request.Form ("OccEntryDate2"
Set objRS3 = objCon.Execute("SELECT * FROM tblView WHERE SubcategoryID=1 AND FieldType='date'"
fieldname = objRS3("FieldName"
Set objRS1 = objCon.Execute("SELECT SelectClause, viewID FROM tblSubCategory WHERE
SubCategoryID=1"
strSQL = objRS1("SelectClause"
& " AND (" & fieldname & " Between '" & occValue & "' AND '" & occValue2 & "') ORDER BY " & fieldname
objRS1.Close
End If
I also tried this line (which didn't work):
strSQL = objRS1("SelectClause"
& " AND (" & fieldname & " > '" & occValue & "' AND < '" & occValue2 & "') ORDER BY " & fieldname
Here are select statments printed out:
This one works, equal search
SELECT * FROM tblTransaction WHERE dateExit IS NULL AND (dateEntry Like'11/19/2001 12:04:06 PM')
ORDER BY dateEntry
This one give error above, inside range search
SELECT * FROM tblTransaction WHERE dateExit IS NULL AND (dateEntry Between'11/17/2001 12:04:06 PM' AND '11/19/2001 12:04:06')) ORDER BY dateEntry
Any ideas would be appreciated.
Thank you
Thunderain
problem with dates. My first search to equal a date gives no error. Works
fine. A second search to find a date inside a range gives a data type
mismatch error. I don't know why I would get this here when the equals
seach does not give this error. It seems that using anything other then "Like" gives data mismatch when dealing with dates. My inside range and all other searchs work with anything other then dates.
ERROR MESSAGE:
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria
expression.
EQUALS SEARCH CODE (this works fine):
If Request.Form("OccEntryDate"
occValue = Request.Form ("OccEntryDate"
Set objRS3 = objCon.Execute("SELECT * FROM tblView WHERE SubcategoryID=1 AND FieldType='date'"
fieldname = objRS3("FieldName"
Set objRS1 = objCon.Execute("SELECT SelectClause, viewID FROM tblSubCategory WHERE SubCategoryID=1"
objRS1.Close
End If
INSIDE RANGE CODE (gives error above):
If Request.Form("OccEntryDate"
occValue = Request.Form ("OccEntryDate"
occValue2 = Request.Form ("OccEntryDate2"
Set objRS3 = objCon.Execute("SELECT * FROM tblView WHERE SubcategoryID=1 AND FieldType='date'"
fieldname = objRS3("FieldName"
Set objRS1 = objCon.Execute("SELECT SelectClause, viewID FROM tblSubCategory WHERE
SubCategoryID=1"
strSQL = objRS1("SelectClause"
objRS1.Close
End If
I also tried this line (which didn't work):
strSQL = objRS1("SelectClause"
Here are select statments printed out:
This one works, equal search
SELECT * FROM tblTransaction WHERE dateExit IS NULL AND (dateEntry Like'11/19/2001 12:04:06 PM')
ORDER BY dateEntry
This one give error above, inside range search
SELECT * FROM tblTransaction WHERE dateExit IS NULL AND (dateEntry Between'11/17/2001 12:04:06 PM' AND '11/19/2001 12:04:06')) ORDER BY dateEntry
Any ideas would be appreciated.
Thank you
Thunderain