How can I cut and paste output from a form?

  • Thread starter Thread starter Billy Smith
  • Start date Start date
B

Billy Smith

I have a form that does a query, processes the records
using VBA, and produces some rows and columns of data
as output. In addition to seeing the results on the form,
my users like to be able to cut and paste the data from
the form to an Excel spreadsheet.

I just wrote the code to put my output into a list box
only to find that I can't cut and paste from a list box.
Even with the Multiselect property set to "Extended",
cut and paste captures only one column of data.

I know a datasheet subform would let me cut and paste but
they're set up for data from queries or tables and I
don't know how to feed data into a datasheet subform
from VBA. I guess I could try writing the output to
a text box but I don't think that will handle the
columns very well.

Questions:

1) Is there an easy way to make the list box let me
cut and paste it's entire contents?

2) If not, how can I write data to a datasheet subform
from VBA code?

3) Any other ideas?

I'm doing this in Access 2000.

Thanks.
 
Using Cut and Paste in an application is a very bad idea. The correct way to
do this is to use the TransferSpreadsheet method (or action) to export the
data to Excel.
 
Thanks for your help. It looks like the TransferSpreadsheet action
requires a table or query as a data source and my data are
in a set of arrays and objects in my VBA code. I guess as a
workaround I could write it all to a table and then use
TransferSpreadsheet.

Why is using cut and paste a bad idea? It seems to work and my users
like it.
 
Losts of chances for errors and possible loss of data in your tables if not
done correctly. Cut and Paste really has no place in a professional Access
application.
 
Back
Top