Advertisements

wrote:
> this works
>
> sSQL = "SELECT *" & _
> " FROM Expenses2008" & _
> " WHERE Amount Like '%" & Request.Form("searchItem") & "%'"
> set rs = Connect.Execute(sSQL)
>
> however if I enter an amount of 99 it not only gives me all entries
> with 99.00 in the Amount collum but 199.00, 1991.72...anything with
> two 9s together.
>
> So I tried
>
> sSQL = "SELECT *" & _
> " FROM Expenses2008" & _
> " WHERE Amount = '" & Request.Form("searchItem") & "'"
> set rs = Connect.Execute(sSQL)
>
> But I get an error message
>
> Microsoft JET Database Engine error '80040e07'
> Data type mismatch in criteria expression.
> /eforms/shiprec/search.asp, line 201
>
>
> Can someone help me with this?
When you use Like, Jet converts the numeric data in your Number field to
strings in order to do the comparison.
When you use = no implicit conversion is performed. Since you are
comparing data contained in a column whose datatype is number to a
literal value contained in quotes (a string) a data type mismatch
occurs. You need to remove the quotes from this line:
" WHERE Amount = '" & Request.Form("searchItem") & "'"
so that it reads:
" WHERE Amount = " & Request.Form("searchItem")

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!