?
Solved

Data type mismatch...

Posted on 2003-03-29
7
Medium Priority
?
175 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
6 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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

601 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