473,465 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

error " data type mismatch!!!!

1 New Member
Anyone can help me why my code keep pop put this error ???
Expand|Select|Wrap|Line Numbers
  1. StrLeaveSql = "SELECT * FROM tblLeave WHERE emp_id = '" & rstReplacement!emp_id & "'" & _
  2.               " AND lea_effective_date = '" & rstReplacement!lea_effective_date & "'" & _
  3.               " AND lea_end_date = '" & rstReplacement!lea_end_date & "'" & _
  4.               " AND lea_leave_type = '" & Me.txt_leave_type & "'"
I want to search the same effective date and end date in the table to edit the leave balance.... pls help me!!
Oct 31 '11 #1
2 1706
pdebaets
16 New Member
You are doing string comparisons for all fields in your SQL statement. Is emp_Id a text field? If it is not, then that could be causing your problem. Try

... WHERE emp_id = " & rstReplacement!emp_id & _ ...

I always surround date values with "#" characters. Ex.: #1/1/2011#. Try that if your problems persist.
Oct 31 '11 #2
NeoPa
32,556 Recognized Expert Moderator MVP
Good advice, but dates in SQL are a little more complicated than just surrounding them in hashes (#) (See Literal DateTimes and Their Delimiters (#) and Quotes (') and Double-Quotes (") - Where and When to use them).

You probably want something like :
Expand|Select|Wrap|Line Numbers
  1. StrLeaveSql = "SELECT * " & _
  2.               "FROM   [tblLeave] "& _
  3.               "WHERE  ([emp_id] = " & rstReplacement!emp_id & ")" & _
  4.               "  AND  ([lea_effective_date] = #" & _
  5.                        Format(rstReplacement!lea_effective_date, "m/d/yyyy") & "#)" & _
  6.               "  AND  ([lea_end_date] = #" & _
  7.                        Format(rstReplacement!lea_end_date, "m/d/yyyy") & "#)" & _
  8.               "  AND  ([lea_leave_type] = '" & Me.txt_leave_type & "')"
Nov 1 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Jack | last post by:
Hi, I am trying to test a sql statement in Access which gives me the error as stated in the heading. The sql statement is built as a part of asp login verification, where the userid and password...
0
by: s_gregory | last post by:
The mdb is considerable size 70 +- mb. A complex union query was working well, but when an additional union select... was added into the query, selecting identical fields from a different source,...
2
by: Chicken Kebab Abdullah | last post by:
Does anyone know why I get the error 3464 Data type mismatch from the following code. I have a form with a combo(to choose a consumable) and 2 list boxes on it. list on left is all printers...
0
by: John Smith | last post by:
Hi I am getting the above error when I try to run the union query shown below select all as , as , as , as , ,, ,, , , as , as , as , as , as from
4
by: Alex | last post by:
help. Deploying a .Net Application using ADO and MS Access (Jet 4.0) and MDAC 2.8. Get error: OleDbError .... Data type mismatch in criteria expression ... The application works fine in...
5
by: David | last post by:
Hi, Getting the following error:- Microsoft JET Database Engine error '80040e07' Data type mismatch in criteria expression. The code is as follows, and the last line is the one that...
1
by: jmarr02s | last post by:
I am using MS Access 2003 and get the following error "Data type mismatch in criteria expression" Any suggestions on how to fix this? This is my code: SELECT IIf(=15 Or =19, "15 og 19",...
6
by: christianlott1 | last post by:
Taken (and modded) from http://www.codeguru.com/vb/gen/vb_misc/tips/ article.php/c13137 'RESULTS' table: REF_STRING - TEXT 250 TEST_STRING - TEXT 250 MATCH_VALU - SINGLE FIXED 2 DECIMAL...
3
by: martin DH | last post by:
I would definitely appreciate any help with this problem as soon as possible. Thanks! I have a report that should display the results of a query based on two tables (tblClient and tblResult,...
14
by: ezechiel | last post by:
Hello, I know others have the same problem here, I tried (a lot! ) different solutions but still can't get around the problem.. :s Here's the code: Private Sub cb_swedit_sopi_AfterUpdate()...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.