- Debug.Print ("update TABLE set REM=REM & ' DB' WHERE ISDATE(Left(DOB,2) & " / " & Mid(DOB,3,2) & " / " & Mid(DOB,5,4)) = 0")
-
CurrentDb.Execute ("update TABLE set REM=REM & ' DB' WHERE ISDATE(Left(DOB,2) & " / " & Mid(DOB,3,2) & " / " & Mid(DOB,5,4)) = 0")
-
same query running very successfully in sql mode while giving type mismatch error in vba code in fact debug.print is also giving type mismatch error - update TABLE set REM=REM & ' DB' WHERE ISDATE(Left(DOB,2) & " / " & Mid(DOB,3,2) & " / " & Mid(DOB,5,4)) = 0
this query is running successfully
Kindly help
4 1117
Hi Try this - Debug.Print "update TABLE set REM=REM & ' DB' WHERE ISDATE(Left(DOB,2) & "" / "" & Mid(DOB,3,2) & "" / "" & Mid(DOB,5,4)) = 0"
You need to double up the quote marks when constructing a string containing/include quotes.
HTH
MTB
NeoPa 32,556
Expert Mod 16PB
The more correct approach (when dealing with SQL strings specifically) is to use the correct SQL quotes as you have done in the first string ( ' DB' ).
Thus, it should be : - Dim strSQL As String
-
-
strSQL = "UPDATE [Table] " _
-
& "SET [REM]=[REM] & ' DB' " _
-
& "WHERE Not IsDate(Left([DOB],2)+'/'+Mid([DOB],3,2)+'/'+Mid([DOB],5,4))"
-
Debug.Print strSQL
-
Call CurrentDb().Execute(strSQL)
NB. Only use + for joining strings when none of the values is Null or when you want Null propagation. I use it here to keep the code shorter. "&" works perfectly well.
NeoPa 32,556
Expert Mod 16PB
To make things perfectly clear - MtB's approach will work, as Jet SQL will happily work with double-quotes in place of the correct SQL quotes (').
The approach indicated will also work in various other scenarios where quotes of either type need to be entered into a string which is, itself, delineated by those same quotes.
So, important and useful to understand, even if not my personal choice as an answer to this specific question.
zmbd 5,501
Expert Mod 4TB Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mudge |
last post by:
Please, someone, tell me why OO in PHP is better than procedural.
|
by: Andrew Thompson |
last post by:
It seems most people get there JS off web sites, which is
entirely logical. But it is also a great pity since most
of that code is of such poor quality.
I was looking through the JS FAQ for any...
|
by: Namratha Shah \(Nasha\) |
last post by:
Hey Guys,
Today we are going to look at Code Access Security.
Code access security is a feature of .NET that manages code depending on its
trust level. If the CLS trusts the code enough to...
|
by: tshad |
last post by:
I am just trying to decide whether to split my code and uses code behind. I
did it with one of my pages and found it was quite a bit of trouble.
I know that most people (and books and articles)...
|
by: KenFehling |
last post by:
Hello. I am wondering if there exists a piece of software that takes
multiple .js files that are nicely indented and commented and create
one big tightly packed .js file. I'm hoping the one file...
|
by: Peter Olcott |
last post by:
Cab you write code directly in the Common Intermediate language? I need to
optimize a critical real-time function.
|
by: blackrosezy |
last post by:
#include
char *code;
void main()
{
char buf = "book";
|
by: rn5a |
last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with
the IDs 'txt1' & 'txt2' respectively. To use this user control in an
ASPX page, the following Register directive will be...
|
by: Jon Skeet [C# MVP] |
last post by:
I'm sure the net will be buzzing with this news fairly soon, but just
in case anyone hasn't seen it yet:
Microsoft are going to make the source code for the .NET framework
(parts of it,...
|
by: AccessCoder |
last post by:
What is the proper way to reference code snippets that are copied from
usenet group examples?
What about when a developer posts code that is copyrighted and they
allow you to use it in a...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
| |