Link to home
Start Free TrialLog in
Avatar of rhakz
rhakz

asked on

Data type mismatch...

Hi,
I'm trying to open a Recordset using a SQL query, my code is like this:

rsSeg.Open "SELECT * FROM Seguimientos WHERE Fecha=#" & fecha & "# AND Hora=#" & hora & "# AND NoCliente='" & Val(lista((indice * 3) + 2)) & "'", DB, adOpenKeyset, adLockOptimistic

Both Fecha and Hora are date types.
Lista is a string array.

The thing is, I always get the "Data Type mismatch in criteria expression" error, even though I have tried several changes.

I'd be glad if u could help me.
Thanks in advance.

Rhakz
Avatar of emadat
emadat
Flag of United States of America image

Try separating your query as follows:

sSQL = "SELECT * FROM Seguimientos WHERE Fecha=#" & fecha & "# AND Hora=#" & hora & "# AND NoCliente='" & Val(lista((indice * 3) + 2)) & "'"
MsgBox(sSQL)
rsSeg.Open sSQL, DB, adOpenKeyset, adLockOptimistic
If you did not get an error message at the first statement; then from the messagebox you will come to see the query.

You can also use Clipoard.SetText sSQL to copy the query to the clipboard; and then paste it into SQL Query analyzer and see i their is something wrong with the query
Avatar of Anthony Perkins
What DBMS (Base de datos) and more specifically what provider are you using?

Anthony
Avatar of PNJ
PNJ

Does your table "Seguimientos" contain valid date values in the columns "Fecha" and "Hora"? I'm just wondering if it's a data related error rather than a VB one. Use MSAcess to have a "visual" look at the data first to see if anything looks unusual. Try sorting on these two columns to see what rises to the top.
ASKER CERTIFIED SOLUTION
Avatar of rhakz
rhakz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi rhakz,
This old question (QID 20567621) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->PAQ - with points refunded

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer