how to export access to excel using "[ID] = " & Me![ID]

splreece

Registered User.
Local time
Today, 08:47
Joined
Jun 2, 2016
Messages
40
Morning all,


I need the ability for users to click a button in the dbase userform and that will select the current record only and save/export the current record to an excel sheet. (this I will then RunCmD to open a word doc merge).

This effectively will mailmerge ONLY the CURRENT Record.

I am struggling to get a working version but I have 2 dbases that use the components of what I want perfectly well.

- I can easily run a report selecting the current record
DoCmd.OpenReport "FrontSheet", , , "[ID] = " & Me![ID]


- I can easily export a dataset to excel
DoCmd.OutputTo acOutputReport, "WordExport", acFormatXLS, "C:\Output.xls"


But I cant seem to figure out how to effectively select the current record only and export it to excel.

any guidance would be great.
 
its the same code
DoCmd.OutputTo acOutputReport, "WordExport", acFormatXLS, "C:\Output.xls"

but in the query :WordExport
it has criteria to reference the form
select * from table where [ID]=forms!myform!txtID
 
Thanks for such a quick reply.

It works great but is asking the user to input the ID number.

Is this because I haven't referenced the forms correctly (therefore can't find the current) or is there something missing where I need to select current record only.
 
Your need the field [ID] in your table, and the form has to be open with a value in the txtID control. I think from your earlier post your control is probably called simply [ID]

However if you always have the form open why not simply link the word doc to the access table or query ?
 

Users who are viewing this thread

Back
Top Bottom