Can anyone tell me how to code the follow to avoid the Syntax Error in FROM cause. I know it is because of my apostophe but I can not change this file name. I got around it once before but can't find how I did it.
Thanks in advance -
-
DELETE *
-
FROM tblRecs IN 'S:\Current\Montey's Restaurant, Inc\Montey's Restaurant\Montey's Restaurant.mdb';
-
-
23 3764 danp129 323
Recognized Expert Contributor
It's a good idea to mention what database you're using when asking for query help. You have a few problems from what I can tell.
1) Apostrophes should be doubled when there is a single apostrophe in the text you're looking for... So if you were wanting to find text in a column that has "Montey's Street" in it you would change it to "Montey''s Street".
2) I don't know that you can specify a table like that in the query (I never had but never used Access much) but I could be wrong. Typically you would open a database and run the query, or specify the database in a connection string and run the query through code. If you are working off an example that actually works, doubling the single apostrophes would fix it. -
DELETE *
-
FROM tblRecs IN ('S:\Current\Montey''s Restaurant, Inc\Montey''s Restaurant\Montey''s Restaurant.mdb');
-
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
Open the said database, and Execute the query: -
Dim MyDB As Database
-
Set MyDB =OpenDatabase("S:\Current\Montey's Restaurant, Inc\Montey's Restaurant\Montey's Restaurant.mdb'")
-
MyDB.Execute "DELETE * FROM tblRecs "
-
MyDb.Close
-
Regards
Veena
- FROM tblRecs IN ('S:\Current\Montey''s Restaurant, Inc\Montey''s Restaurant\Montey''s Restaurant.mdb');
worked perfectly thanks. Sorry with the holidays this is the first I got back to it.
Thanks again.
Sorry spoke to soon. When I tried to run the query it said it was the wrong path. Still having a problem.
@clloyd
did you try as suggested in post #3 ?
Yes (Post #3) I received the error message "Invalid SQL Statement 'Delete' , 'Insert', 'Procecedure', 'Select', OR 'Update'
try the following -
con.Begintrans 'con---ADODB connection object.
-
con.execute "delete from table_name where condition"
-
con.Committrans
-
-
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
Can you check the Path again..? If the error says, Wrong Path, then there must be some problem with the Path, (May be An Extra Space or so..)
Regards
Veena
The path is correct. It is the apostrophe in the clients name that is causing the problem and I don't know how to get around it. You can not [ ] around the path or the name that I can find that will work.
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
Whatever I suggested in my First Post works Perfectly,
Open DAO database, and execute Query ,
I have Tested with All kind of special characters, Apostrophe, Space etc..
Regards
Veena
Are you referring to -
-
Dim MyDB As Database
-
Set MyDB =OpenDatabase "S:\Current\Montey's Restaurant, Inc\Montey's Restaurant\Montey's Restaurant.mdb'")
-
MyDB.Execute "DELETE * FROM tblRecs "
-
MyDb.Close
-
?
I receive the following error as I mentioned before: Invalid SQL Statement; expected 'Delete', 'Insert', 'Procedure', 'Select', or 'Update'
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
Remove * from the query :
MyDB.Execute "DELETE FROM MyTable"
Regards
Veena
How does it then know what table to delete from?
that will delete all the records from the table
So you are saying the code would read as follows: -
Dim MyDB As Database
-
Set MyDB =OpenDatabase "S:\Current\Montey's Restaurant, Inc\Montey's Restaurant\Montey's Restaurant.mdb'")
-
MyDb.Close
-
I have numerous tables in this database. I still do not understand how it knows which table to delete from reading the code as I have it above. I am not an expert so if I am missing something I apologize.
I went ahead and tried it removing MyDB.Execute "DELETE FROM MyTable" and still got the Invalid SQL Statement; expected 'Delete', 'Insert', 'Procedure', 'Select', or 'Update' error
I think in your code MyTable is the name of the table.
No matter what I do this code does not work. I will keep searching.
do you understand the code ,you have written
I don't think you understand the difference between a database and a table.
Please use ADO and follow as per post#8
No I don't understand post 8. I am not an expert programmer. I do understand however the difference between a table and a database though. That was a little harsh.
try something like this -
Dim CON As New ADODB.Connection
-
-
Private Sub Command1_Click()
-
CON.Open "Provider=MSDAORA.1;Password=DEBASIS;User ID=DEBASIS;Data Source=DAS;Persist Security Info=True" --change to your own connectionstring
-
CON.BEGINTRANS
-
CON.EXECUTE "DELETE FROM TABLE1" --USE YOUR DELETE STATMENT HERE
-
CON.COMMITTRANS
-
Endsub
-
QVeen72 1,445
Recognized Expert Top Contributor
Hi
Where are you writing the Code..? in VB6 or in VBA...?
Regards
Veena
VBA. Sorry to take so long I was on other projects.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: shank |
last post by:
1) I'm getting this error: Syntax error (missing operator) in query
expression on the below statement. Can I get some advice.
2) I searched ASPFAQ and came up blank. Where can find the "rules"...
|
by: Dave |
last post by:
I have 2 tables, one with names, and another with addresses, joined by their
CIVICID number (unique to the ADDRESSINFO table) in Oracle.
I need to update a field in the NAMEINFO table for a...
|
by: Martin |
last post by:
I am now working on SQL Server 2000 having had previous experience on
a different database. Both of the OUTER JOIN syntaxes is different
from what I am used to and I am finding it slightly...
|
by: Jan van Veldhuizen |
last post by:
The UPDATE table FROM syntax is not supported by Oracle.
I am looking for a syntax that is understood by both Oracle and SqlServer.
Example:
Table1:
id name city ...
|
by: sunny076 |
last post by:
Hi,
I am confused with the syntax for NOT in MYSQL where clause and wonder
if an expert in MYSQL can enlighten me. There are possibly two places
NOT can go in:
select * from employee_data...
| |
by: tom |
last post by:
I am new to SQL administration.
>From a list of IDs that are the primary key in one table (i.e. Customer
Table), I want to make changes in tables that use those IDs as a
foreign key.
...
|
by: James |
last post by:
Please help me with this sql:
SELECT z005aNORTHEAST_3days_Formula.Region,
z005aNORTHEAST_3days_Formula.DiffofClaimsAssignment
FROM (SELECT .Region, (.)-(
.) AS DiffofClaimsAssignment
FROM...
|
by: Jerry |
last post by:
Well, here is some weirdness. First, I noticed that I
have 2 Set keywords (silly me). so I removed the
2nd "Set" but still got a syntax error. Then I removed
the Where clause, and now it works...
|
by: Frankie |
last post by:
Hello:
New user here...first post to group.
I'm getting an SQL syntax error when I try to run the following query:
$query = sprintf("SELECT itemNumber, entryDate, modifyDate, thumbnailURL,...
|
by: bilbo |
last post by:
Can anybody help me understand why I get the error
"Syntax error in CONSTRAINT clause"?
I get it in Access 2003 and Access 2007.
Both are clean installs with no add-ins
Running this code in...
|
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...
| |
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |