Solved

Need help with simple access sql statement

Posted on 2013-11-08
10
469 Views
Last Modified: 2013-11-08
Hello, I'm trying to understand why the following does not work in Access SQL. Please forgive the basic crud. This would work in MS SQL, but when I try it in Access I get the following error:

Syntax error in from clause

What am I doing wrong?

DELETE *  FROM Table1

INSERT INTO Table1(email, productid, datecreated, datesend) values ('adf', 5, '10/10/2012','10/10/2012')

Select * from Table1;
0
Comment
Question by:gogetsome
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39633870
in access date/time field need to be wrap in # tags

try this

INSERT INTO Table1(email, productid, datecreated, datesend) values ('adf', 5, #10/10/2012#,#10/10/2012#)
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 39633873
INSERT INTO Table1(email, productid, datecreated, datesend) values('adf', 5, '10/10/2012','10/10/2012')

You can not have a space after values
0
 
LVL 51

Accepted Solution

by:
Gustav Brock earned 250 total points
ID: 39633894
You need two queries:

DELETE *  FROM Table1

and

INSERT INTO
Table1 (email, productid, datecreated, datesend)
values ('adf', 5, #10/10/2012#, #10/10/2012#)

/gustav
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:gogetsome
ID: 39633907
This does not work as well, with same error


DELETE *  FROM Table1

INSERT INTO Table1(email, productid, datecreated, datesend) values ('adf', 5, #10/10/2012#,#10/10/2012#)

Select * from Table1;

gustav, are you say in access sql you can't run multiple statements in one query?
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 39633919
Yes.
But you can easily execute one after the other.

/gustav
0
 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 39633935
Actually you need three:

DELETE *  FROM Table1

And

INSERT INTO Table1(email, productid, datecreated, datesend) values ('adf', 5, '10/10/2012','10/10/2012')
 
And

Select * from Table1;

You can use single quotes to delimit dates in Access, but the documented method is the hashmark.

You don't need a space after VALUES.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39633942
you can run multiple separate sql statements using vba codes, this will run the queries in succession

docmd.runsql "DELETE *  FROM Table1"

docmd.runsql  "INSERT INTO Table1(email, productid, datecreated, datesend) values('adf', 5, #10/10/2012#,#10/10/2012#)"
0
 

Author Comment

by:gogetsome
ID: 39633947
Okay, making much more sense now... I suppose I need to do what I want in VBA to execute the various queries I need?

How should I divide up the points? :-)
0
 

Author Closing Comment

by:gogetsome
ID: 39634232
Thanks guys!
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39634240
;-)
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question