I have been searching this online for hours without luck. I have a subform embedded in my main form. The subform's recordsource is from a SQL result based on some filtering criteria user sets in the main form. After user clicks "Search", data gets populated in my subform. Most of its controls are then bound. However, I also have an unbound control in my subform. This unbound control gets data from a separate SQL based on the values of my other controls' values. Everything in my subform is presented in a datasheet view.
Now, I would like to design an "export" function that allows user to save the current search result in my subform datasheet into an Excel file. I have tried the following ways:
DoCmd.OutputTo acOutputForm, "my_Subform", acFormatXLS, exportFile & ".xls"
This only gives me the header of my subform without any data.
I have also tried to use CopyFromRecordset function. However, as I mentioned my subform has one control that is not bound to the record source of the subform. I can store the SQL object and do CopyFromRecordset, but this gives me only data from the bounded controls.
Thanks a lot in advance.