Run SQL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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.
 
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.
 
Back
Top