?
Solved

Data type mismatch...

Posted on 2003-03-29
7
Medium Priority
?
174 Views
Last Modified: 2010-05-01
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
0
Comment
Question by:rhakz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 3

Expert Comment

by:emadat
ID: 8231833
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
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 8232765
What DBMS (Base de datos) and more specifically what provider are you using?

Anthony
0
 
LVL 3

Expert Comment

by:PNJ
ID: 8239570
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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Accepted Solution

by:
rhakz earned 0 total points
ID: 8242328
I finally found my mistake.
Instead of doing:
"NoCliente='" & whatever & "'"

It is:
"NoCliente=" & whatever

Thanks to everyone for their answers though :)

Rhakz
0
 

Expert Comment

by:CleanupPing
ID: 8531348
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.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9440693
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
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question