Solved

Need help with simple access sql statement

Posted on 2013-11-08
10
455 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 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 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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
 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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.
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…
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…

821 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