Syntax Errors

G

Guest

I am trying to delete the data is the Summary-Test table and then insert the
data from the summary table. If I run either of these queries separately
they run just fine, but when I combine them then I get an error message,
either the Syntax Error in from clause and it then highlights the INSERT INTO
part of the query. or a Syntax Error (comma) in query expression. the SQL
information is below. Please note any changes that need to be made so I
learn what I did wrong. I am running ACCESS 2002-2003. I have also received
an invalid bracketing error. While I have used and created and maintain a
number of ACCESS databases I have not tried to create a delete data in table
then create table query in SQL before.

DELETE [Summary-Test].ID, [Summary-Test].Date, [Summary-Test].[Order No],
[Summary-Test].Item, [Summary-Test].Description, [Summary-Test].QTY,
[Summary-Test].[Matl Cost], [Summary-Test].[Total Matl Cost],
[Summary-Test].Cost, [Summary-Test].[Total Cost], [Summary-Test].Keep,
[Summary-Test].DistributorNo
FROM [Summary-Test] " & _

INSERT INTO [Summary-Test] ( [Date], ID, [Order No], Item, Description, QTY,
[Matl Cost], [Total Matl Cost], Cost, [Total Cost], Keep, DistributorNo )
SELECT Summary.Date, Summary.ID, Summary.[Order No], Summary.Item,
Summary.Description, Summary.QTY, Summary.[Matl Cost], Summary.[Total Matl
Cost], Summary.Cost, Summary.[Total Cost], Summary.Keep, Summary.DistributorNo
FROM Summary
WHERE (((Summary.Date) Between [What is the starting date?] And [What is the
Ending Date?]));


Thank you.
 
P

pietlinden

You can't run them both as a single statement.
separate out the INSERT statement and DELETE statements, and then do
something like

or
CurrentDB.Execute strInsertStatement
CurrentDB.Execute strDeleteStatement
 
P

pietlinden

you don't.
create two queries. One to do the Insert, a Second to do the update.
create a macro.

SetWarnings False
OpenQuery "InsertQuery"
OpenQuery "DeleteQuery"
SetWarnings True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top