473,404 Members | 2,187 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,404 software developers and data experts.

Access query help needed !!

26
I want to run a update query
Expand|Select|Wrap|Line Numbers
  1. accApp.OpenCurrentDatabase sRawDatabaseName
  2. accApp.DoCmd.TransferText acImportDelim, "DataImportSpec", "tblRaw", sLocalDataFile, False
  3. accApp.DoCmd.RunSQL  "Update tblRaw SET tblData.MaturityDate="" WHERE BookCode="123-America" AND StrategyID IN('420','320','220');"
This sRawDatabaseName is C:\Documents and Settings\All Users\Documents\Data.mdb

Access doesn't accept this SQL
Expand|Select|Wrap|Line Numbers
  1. "Update tblRaw SET tblData.MaturityDate="" WHERE BookCode="123-America" AND StrategyID IN('420','320','220');"
Whereas I run it , by saving the intermediate database and it works fine .I run in that database manually
Expand|Select|Wrap|Line Numbers
  1. Update tblData SET MaturityDate=""  WHERE BookCode="123-America" AND StrategyID IN('420','320','220');
Please help immediately if possible.Many thanks in advance !!
Jun 30 '10 #1

✓ answered by thelonelyghost

First off, for the sake of clarity, don't be afraid to use the [code] boxes in this forum.

Onto your issue. Your SQL is in the form of a string. What this means is that Access chokes when you use quotes in the way you did:
Expand|Select|Wrap|Line Numbers
  1. "Update tblRaw SET tblData.MaturityDate="" WHERE BookCode="123-America" AND StrategyID IN('420','320','220');"
It currently sees it as three separate strings:

Expand|Select|Wrap|Line Numbers
  1. Update tblRaw SET tblData.MaturityDate=" WHERE BookCode=
  2. 123-America
  3.  AND StrategyID IN('420','320','220');
The above doesn't even have any sort of concatenation symbol ( & ) so Access panics and doesn't know what to do. If you change it to this, it may solve your issue:
Expand|Select|Wrap|Line Numbers
  1. "Update tblRaw SET tblData.MaturityDate='' WHERE BookCode='123-America' AND StrategyID IN('420','320','220');"
EDIT: Nice link, NeoPa! I didn't know it existed, but c'est tres utile!

5 1395
NeoPa
32,556 Expert Mod 16PB
Your setting of :
Expand|Select|Wrap|Line Numbers
  1. MaturityDate=""
will not work as you have it from within a SQL string. It will see that as :
Expand|Select|Wrap|Line Numbers
  1. MaturityDate="
See Quotes (') and Double-Quotes (") - Where and When to use them.
Jun 30 '10 #2
thelonelyghost
109 100+
First off, for the sake of clarity, don't be afraid to use the [code] boxes in this forum.

Onto your issue. Your SQL is in the form of a string. What this means is that Access chokes when you use quotes in the way you did:
Expand|Select|Wrap|Line Numbers
  1. "Update tblRaw SET tblData.MaturityDate="" WHERE BookCode="123-America" AND StrategyID IN('420','320','220');"
It currently sees it as three separate strings:

Expand|Select|Wrap|Line Numbers
  1. Update tblRaw SET tblData.MaturityDate=" WHERE BookCode=
  2. 123-America
  3.  AND StrategyID IN('420','320','220');
The above doesn't even have any sort of concatenation symbol ( & ) so Access panics and doesn't know what to do. If you change it to this, it may solve your issue:
Expand|Select|Wrap|Line Numbers
  1. "Update tblRaw SET tblData.MaturityDate='' WHERE BookCode='123-America' AND StrategyID IN('420','320','220');"
EDIT: Nice link, NeoPa! I didn't know it existed, but c'est tres utile!
Jun 30 '10 #3
NeoPa
32,556 Expert Mod 16PB
Thanks LePhantasmSeul :)

We have a bunch of articles on the site in Access. I try to link to them where I can. It saves reinventing the wheel every time, which can get a little tedious.

PS. I just got back from Paris at the weekend so my French is as good as it gets ATM :D
Jun 30 '10 #4
titli
26
Thanks All ...for your responses and explanations....Yes, the last update query in the link , worked fine.
Jul 1 '10 #5
NeoPa
32,556 Expert Mod 16PB
Thanks for the response Titli. Glad that helped.

I'm going to set post #3 as best as the explanation there is the clearest and fullest.
Jul 1 '10 #6

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

Similar topics

5
by: Art | last post by:
Hi, Can anyone point me to an example of how I would execute a query I've created in an Access DB. I've copied the SQL down to my VB.net application and that works fine, but it's ugly. I'd like...
8
by: s_wadhwa | last post by:
SELECT DISTINCTROW "01C" AS dummy, Buildings.BuildingNumber, UCASE(Buildings.BuildingName) AS BuildingName, Buildings.MasterPlanCode, Buildings.UniformBuildingCode,...
4
by: ShastriX | last post by:
Getting a weird error while trying out a query from Access 2003 on a SQL Server 2005 table. Want to compute the amount of leave taken by an emp during the year. Since an emp might be off for...
12
by: zwasdl | last post by:
Hi, I'm using MS Access to query against Oracle DB via ODBC. Is it possible to use HINT in Access? Thanks, Wei
2
by: k-man | last post by:
Hi: I have an MS Access query for a table called MyTable. One of my fields in the query is a custom field that looks like "MyField: = MyFunction(ID)" where ID is a field in MyTable. I have...
4
by: pkerr2003 | last post by:
I want to list all groups within my data regardless of whether they meet a certain condition - if they do not meet the condition I want to display a count of 0 for the relevant groups. Access...
6
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one...
2
by: markvolz | last post by:
Hi, I have an access query. Currently it runs fine except now I would like it to run silently. I set task scheduler to run it as needed. However, I need to have it run silently without having...
15
by: OzNet | last post by:
I have a query (with calculated fields) in Access (2007) and the data changes depending on the dates and staff person selected. I need to produce a series of graphs based on the data in this query...
0
by: uno7031 | last post by:
Help Please!!! Adding 5 Days to another Date in an access query Good Morning, Help please…. I am new to access and trying to write a query that will add 5 days between a RecDate and a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.