473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

type mismatch error

232 100+
Expand|Select|Wrap|Line Numbers
  1. CurrentDb.Execute ("update emp set rmk=rmk &'1' WHERE ISDATE(LEFT(DOB,2) & " / " & MID(DOB,3,2)& " / " & MID(DOB,5,4))=0")
vs
Expand|Select|Wrap|Line Numbers
  1. update emp set rmk=rmk &'1' WHERE ISDATE(LEFT(DOB,2) & " / " & MID(DOB,3,2)& " / " & MID(DOB,5,4))=0
same query within double quote runs fine in query editor
while gives type mismatch error while running in vba sub.kindly guide
Oct 9 '13 #1
2 939
Hi kkshansid

I am a little in doubt. Is the field rmk a string? And are the purpose to add the character ‘1’ to the value in that field?
For instance, update the value ‘abc’ to ‘abc1’?

First of all, try to insert spaces:

Expand|Select|Wrap|Line Numbers
  1. CurrentDb.Execute ("update emp set rmk=rmk &*space*'1' WHERE ISDATE(LEFT(DOB,2) & " / " & MID(DOB,3,2)*space*& " / " & MID(DOB,5,4))=0")
Best regards
Stef
Oct 9 '13 #2
zmbd
5,501 Expert Mod 4TB
It isn't running in VBA more than likely because you haven't properly escaped your quotes.

You've stumbled upon one of my pet peeves by building the criteria string within the command - and it's not your fault because that's how a majority of examples show how to use the command.

Instead I suggest that you build the string first and then use the string in the command. Why you might ask, because you can then check how the string is actually resolving; thus, making troubleshooting the code so much easier as most of the time the issue is with something missing or not resolving properly/as expected within your string.

So to use your code:
Expand|Select|Wrap|Line Numbers
  1. '(the following is partially air-code)
  2. DIM daoDB as DAO.Database
  3. DIM strSQL as string
  4. '
  5. set daoDB = CurrentDB
  6. '
  7. '
  8. strSQL = "update emp set rmk = rmk & '1' " & _
  9.    "WHERE (ISDATE(LEFT(DOB,2)" & _
  10.    " / " & Mid(dob, 3, 2) & _
  11.    " / " & Mid(dob, 5, 4) & "=0)"
  12. '
  13. 'now you can insert a debug print here for troubleshooting
  14. ' - press <ctrl><g> to open the immediate window
  15. ' - you can now cut and paste this information for review!
  16. '
  17. debug.print "Your criteria = " & strSQL
  18. '
  19. 'now use the string in your code:
  20. daoDB.Execute
  21.  
  22. if not daoDB is nothing then set daoDB = Nothing
  23.  
  24.  
I think you are going to find that your string isn't resolving the way you expect it to.
Also note that I set a variable to hold the pointer to the current database. If you are using multiple "currentdb" references within you're code, you are potentially tying up system resources that might also cause you other issues.

Your WHERE clause is also a bit clunky... why wouldn't your DOB field at the table level be set to a date/time type-cast?

You might also find the following information also very helpful: Quotes (') and Double-Quotes (") - Where and When to use them
Oct 9 '13 #3

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

Similar topics

4
by: leslie_tighe | last post by:
Hello, I have a method on a com+ object that is returning an array of objects. I know the array is popluated as calls to check the ubound and lbound show valid values. However, any calls to...
4
by: Mike | last post by:
I am getting a type mismatch error when I do a bulk insert. ---Begin Error Msg--- Server: Msg 4864, Level 16, State 1, Line 1 Bulk insert data conversion error (type mismatch) for row 1, column...
6
by: shan | last post by:
What is the meaning for the error expression syntax and type mismatch error.I am using turbo c++.can anybody correct the errors in the folowing program. Following program is to find matrix...
1
by: jodyblau | last post by:
I am getting a type mismatch message under strange circumstances. Here's whats going on: 1. I have split the database into a front end and a back end. 2. I have compiled the project. 3. ...
2
by: Rehan | last post by:
Hi there! Please help me out here. I am an inch away from completing my assignment. I am very new to VBA but i have very less time to be efficient at it. I am getting a type mismatch error...
5
by: kjworm | last post by:
Hello Everyone, I have been fighting with a type mismatch error for many hours today and I can't seem to find what the problem is. Hopefully it is more than a missing apostrophe! I have isolated...
7
by: Mike | last post by:
Type Mismatch error I recieve a type mismatch error on the following line of code which is based on a specific date. It does NOT break on all records only "some". The dates for the records...
5
by: Lara1 | last post by:
Hi, I'm a total beginner to VBA, so please bear with me if I seem a bit dense. What I'm Trying to Achieve I'm trying to write a procedure in Excel, which is supposed to - look at the pH...
1
by: sharbha | last post by:
I am experiencing a VBScript runtime error. The error message is: "(0x800A000D)Type mismatch error" Here is my code: <% dim temp temp=session("items") ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.