473,503 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Syntax Error in FROM clause

93 New Member
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. DELETE *
  3. FROM tblRecs IN 'S:\Current\Montey's Restaurant, Inc\Montey's Restaurant\Montey's Restaurant.mdb';
  4.  
  5.  
Dec 22 '08 #1
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.

Expand|Select|Wrap|Line Numbers
  1. DELETE * 
  2. FROM tblRecs IN ('S:\Current\Montey''s Restaurant, Inc\Montey''s Restaurant\Montey''s Restaurant.mdb'); 
  3.  
Dec 22 '08 #2
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Open the said database, and Execute the query:

Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As Database
  2. Set MyDB =OpenDatabase("S:\Current\Montey's Restaurant, Inc\Montey's Restaurant\Montey's Restaurant.mdb'")
  3. MyDB.Execute "DELETE *  FROM tblRecs "
  4. MyDb.Close
  5.  
Regards
Veena
Dec 23 '08 #3
clloyd
93 New Member
Expand|Select|Wrap|Line Numbers
  1.  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.
Dec 30 '08 #4
clloyd
93 New Member
Sorry spoke to soon. When I tried to run the query it said it was the wrong path. Still having a problem.
Dec 30 '08 #5
debasisdas
8,127 Recognized Expert Expert
@clloyd
did you try as suggested in post #3 ?
Dec 30 '08 #6
clloyd
93 New Member
Yes (Post #3) I received the error message "Invalid SQL Statement 'Delete' , 'Insert', 'Procecedure', 'Select', OR 'Update'
Jan 7 '09 #7
debasisdas
8,127 Recognized Expert Expert
try the following

Expand|Select|Wrap|Line Numbers
  1. con.Begintrans         'con---ADODB connection object.
  2. con.execute "delete from table_name where condition"
  3. con.Committrans
  4.  
  5.  
Jan 7 '09 #8
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
Jan 8 '09 #9
clloyd
93 New Member
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.
Jan 8 '09 #10
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
Jan 9 '09 #11
clloyd
93 New Member
Are you referring to


Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim MyDB As Database 
  3. Set MyDB =OpenDatabase "S:\Current\Montey's Restaurant, Inc\Montey's Restaurant\Montey's Restaurant.mdb'") 
  4. MyDB.Execute "DELETE *  FROM tblRecs " 
  5. MyDb.Close 
  6.  

?

I receive the following error as I mentioned before: Invalid SQL Statement; expected 'Delete', 'Insert', 'Procedure', 'Select', or 'Update'
Jan 12 '09 #12
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Remove * from the query :

MyDB.Execute "DELETE FROM MyTable"

Regards
Veena
Jan 13 '09 #13
clloyd
93 New Member
How does it then know what table to delete from?
Jan 13 '09 #14
debasisdas
8,127 Recognized Expert Expert
that will delete all the records from the table
Jan 14 '09 #15
clloyd
93 New Member
So you are saying the code would read as follows:
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As Database  
  2. Set MyDB =OpenDatabase "S:\Current\Montey's Restaurant, Inc\Montey's Restaurant\Montey's Restaurant.mdb'")  
  3. MyDb.Close
  4.  
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.
Jan 14 '09 #16
clloyd
93 New Member
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
Jan 14 '09 #17
debasisdas
8,127 Recognized Expert Expert
I think in your code MyTable is the name of the table.
Jan 14 '09 #18
clloyd
93 New Member
No matter what I do this code does not work. I will keep searching.
Jan 15 '09 #19
debasisdas
8,127 Recognized Expert Expert
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
Jan 15 '09 #20
clloyd
93 New Member
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.
Jan 15 '09 #21
debasisdas
8,127 Recognized Expert Expert
try something like this

Expand|Select|Wrap|Line Numbers
  1. Dim CON As New ADODB.Connection 
  2.  
  3. Private Sub Command1_Click() 
  4. CON.Open "Provider=MSDAORA.1;Password=DEBASIS;User ID=DEBASIS;Data Source=DAS;Persist Security Info=True" --change to your own connectionstring
  5. CON.BEGINTRANS
  6. CON.EXECUTE "DELETE FROM TABLE1"  --USE YOUR DELETE STATMENT HERE
  7. CON.COMMITTRANS
  8. Endsub
  9.  
Jan 15 '09 #22
QVeen72
1,445 Recognized Expert Top Contributor
Hi

Where are you writing the Code..? in VB6 or in VBA...?

Regards
Veena
Jan 16 '09 #23
clloyd
93 New Member
VBA. Sorry to take so long I was on other projects.
Jan 22 '09 #24

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

Similar topics

29
2477
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"...
7
248434
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...
2
18102
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...
8
3294
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 ...
2
15752
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...
8
4318
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. ...
4
5140
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...
3
3097
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...
11
1855
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,...
3
5196
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...
0
7328
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
6988
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
7456
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
5578
agi2029
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,...
1
5011
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...
0
3166
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
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
bsmnconsultancy
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...

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.