Code Snippets → Export A Form’s Recordset To Excel

Copy this code into a standard (not form or report) module. Name the module something other than this function name and make sure to set a reference to DAO if you don’t have one set already.

You can then call it like this for a form (if the code is on the form you want then):

To use it with a form which the code is not on use (the form must be open):

To use it with a subform and the code not be on the subform:


Just a note – SubformControl means the control on the main form which houses the subform and not the subform name itself (unless they share the same name).