Exporting a record to text file

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

Guest

Hi,
I have a continuous form with records from a single table. I would like to
add a command button that would export the selected record to a text file.
Can someone help me with the code to do this or direct me to a place where I
can find what I need?

Thanks,
 
Hi Phil,

Create a select query that returns the fields you want, with a criterion
that gets a value from a control on the form to identify the record.
E.g. if the table is tblT, its primary key is the field IDNum, and IDNum
is displayed in the textbox txtIDNum on the form frmF, the SQL view of
the query might look like this (minus the superflous parentheses that
Access's query designer introduces):

SELECT * FROM tblT WHERE IDNum = Forms!frmF!txtIDNum;

The query should return just one record, the current one. So then you
just have your commandbutton call DoCmd.TransferText to export the query
to a text file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top