Run SQL

M

Michelle

I have a form and when the user clicks the exit button I want it to run the
following code....one is an append query and the other is a delete query.

Here is the code
Append Query.....
INSERT INTO tblESSOld ( ESSID, IN_INMNUM, SEP, EXERCISE, SHOWER, [YARD #],
RAZOR, SCREAM, MIRROR, [DATE] )
SELECT tblESSLog.ESSID, tblESSLog.IN_INMNUM, tblESSLog.SEP,
tblESSLog.EXERCISE, tblESSLog.SHOWER, tblESSLog.[YARD #], tblESSLog.RAZOR,
tblESSLog.SCREAM, tblESSLog.MIRROR, tblESSLog.DATE
FROM tblESSLog;

Delete Qury...
DELETE tblESSLog.*
FROM tblESSLog;

Could the delete and append be make into one statemen...was not sure about
that....also after it runs the two quieries I want it to close the form.
 
D

Douglas J Steele

It's not possible to combine them into a single statement.

You could create a transaction that wraps the two individual statements, so
that the deletion wouldn't take place unless the insertion was successful.

Once the queries have run successfully, you simply close the form, the same
as you would if you weren't running the queries.
 
M

Michelle

How would I get the command button to run both statements?

Douglas J Steele said:
It's not possible to combine them into a single statement.

You could create a transaction that wraps the two individual statements, so
that the deletion wouldn't take place unless the insertion was successful.

Once the queries have run successfully, you simply close the form, the same
as you would if you weren't running the queries.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Michelle said:
I have a form and when the user clicks the exit button I want it to run the
following code....one is an append query and the other is a delete query.

Here is the code
Append Query.....
INSERT INTO tblESSOld ( ESSID, IN_INMNUM, SEP, EXERCISE, SHOWER, [YARD #],
RAZOR, SCREAM, MIRROR, [DATE] )
SELECT tblESSLog.ESSID, tblESSLog.IN_INMNUM, tblESSLog.SEP,
tblESSLog.EXERCISE, tblESSLog.SHOWER, tblESSLog.[YARD #], tblESSLog.RAZOR,
tblESSLog.SCREAM, tblESSLog.MIRROR, tblESSLog.DATE
FROM tblESSLog;

Delete Qury...
DELETE tblESSLog.*
FROM tblESSLog;

Could the delete and append be make into one statemen...was not sure about
that....also after it runs the two quieries I want it to close the form.
 

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

Similar Threads

Compiler Error....Syntax Error.... 1
Union Query Problem 4
Left Join 2
Join Issues (can not enter data) 1
Union Query Issue 1

Top