Can I print report and then delete at the same time?

  • Thread starter Thread starter Norm
  • Start date Start date
Define "deleted"...

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
I would not do this. Perhaps you can describe the problem you are trying to
solve by doing this.

You might be able to execute a delete query in the close event of the report,
but if you changed your mind or the printer jammed you would have no way to
try to print the information again.

I would mark the records for deletion (use a boolean field or dateTime field
named DeleteRecord). You could then run a separate process to actually delete
the records once you had successfully printed hardcopy.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
Thanks John,
This is a report that is not big enough to worry about having to re-do, I
have put a control button to delete record and it works fine but only deletes
one line at a time,can i change that control to delete the entire sheet at
once?
 
If you are using a subform, then the records that are being displayed are
normally filtered by some value (or values) on the main form.

If you can grab that value you should be able to write a delete query that
will delete all the relevant records in the subform.

strSQL = "DELETE FROM [TheSubFormTable] WHERE [TheSubFormTable].[SomeField] "
& TheValueFromTheMainForm

Currentdb().Execute strSQL

I would be sure to backup and test first to make sure this works as expected.

Another alternative would be to build and store a delete query that references
a control on the parent form that has the value. And then execute that stored
query.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
The query worked Thanks for your help!!

John Spencer said:
If you are using a subform, then the records that are being displayed are
normally filtered by some value (or values) on the main form.

If you can grab that value you should be able to write a delete query that
will delete all the relevant records in the subform.

strSQL = "DELETE FROM [TheSubFormTable] WHERE [TheSubFormTable].[SomeField] "
& TheValueFromTheMainForm

Currentdb().Execute strSQL

I would be sure to backup and test first to make sure this works as expected.

Another alternative would be to build and store a delete query that references
a control on the parent form that has the value. And then execute that stored
query.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
Thanks John,
This is a report that is not big enough to worry about having to re-do, I
have put a control button to delete record and it works fine but only deletes
one line at a time,can i change that control to delete the entire sheet at
once?
.
 
Back
Top