Want to export only single row of table - any ideas?

  • Thread starter Thread starter PurpleHeather
  • Start date Start date
P

PurpleHeather

Guest
Hi there
First posting on here but have read the threads before for assistance/tips.

I have a successful line of VBA that exports a table and names it how I need it to be named. The filepath/name are as I need them and relate to the open record - inc the values of 2 fields in the filename. So far so good.

I need only to see a single row of fieldheaders and a single row of data.
How can I amend my code to do this? Is it simple and I'm just being daft?

DoCmd.TransferSpreadsheet acExport, , "tblOfferData", "D:\data\CR_" & MPNPolicy & "_" & CalcNo & "_O.xls", True

Thanks,

PurpleHeather
 
Last edited:
Export a query instead of the whole table. Define your query field criteria to get the one record you want to transfer to the Excel file.
 
Cheers mate.

I had considered a query but want it automatically executed for the open record (primary key = CalcNo - shown on the form).
My current code is automatic but provides too much data.

The only way I can think for the query to work is to get the user to enter the primary key manually when the query is executed. Not an automatic solution :(

Any idea on the automation of this?

(apologies that I'm so ignorant - I'm an Access VBA newbie - used to Excel VBA and am stumbling on a few Access-specific areas)
 
The query will be "automatic" for it will be the source of your transferspreadsheet method. Link the parameter for the primary key [CalcNo] field in your query to the field on the form so that the current record is transfered to the Excel file. The user will never have to do anything except click your button to create the Excel file.
 

Users who are viewing this thread

Back
Top Bottom