Solved

Need help with simple access sql statement

Posted on 2013-11-08
10
465 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 50

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 50

Expert Comment

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

/gustav
0
 
LVL 84

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

751 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