Export data from current record to csv

  • Thread starter Thread starter DaveB
  • Start date Start date
D

DaveB

Hi,

I want to add a command button to a form so that when a user clicks it
certain fields from the current record on that form are exported to a csv
file. At present the fields get exported for all records in that table.
1) Can I run a command that just exports the relevant fields from the
"current/selected" reord
2) Is there a way to prevent the data being output with "literals" (quotes)
around each field?
All help/advice will be gratefully received!
Regards - David
 
Dave

One approach might be to create a query that uses a Selection Criterion to
return only the record being displayed on the form. Then your command
button could "export" that query. In the query you could try using the
conversion functions (e.g., CInt(), CDate(), ...) to determine the output.
You might need to work with the export-related function
(?TransferSpreadsheet?) to see about the quotes.

Good luck!

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
Hi Jeff

Thanks for the advice. Can you please advise me what the expression
criteria is to return only the record being displayed on the form?

Kind regards - Dave
 
Dave

I don't know how you are selecting the record to display on the form?!

I don't know what query you are using to "select" that record.

The concept (but not the specific expression) is that you'll need to have a
way to uniquely identify the record on display. A primary key field would
do that.

Then, in your query, you could use something like:

Forms!YourForm!YourPrimaryKeyFieldControl

as a selection criterion for the primary key field in the query, to tell the
query to use what the form has.

NOTE: your form must be open and a record selected for this approach to
work.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
Jeff

Apologies for the delay in replying. I have successfully managed to get
your "concept" to work with my form. Many thanks for your excellent advice!

Regards - Dave
 
Back
Top