Solved

Need help with simple access sql statement

Posted on 2013-11-08
10
426 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
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
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 49

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
 

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 49

Expert Comment

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

/gustav
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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 119

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
ID: 39634240
;-)
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now