So i have an MS Access form that with predefined fields that are linked to different tables in my MS Access DB. What i want to do is take the information from each textbox in the form and make that into a spread sheet in excel and then save that to a predefined folder. I currently have no code and i am not sure how to execute this. I am trying to keep all the code tied to a button on the form so that you can load the form and then press the button.
not sure what else to include but i am using MS Access 2013 and Excel 2013.
Thanks in advance
答案 0 :(得分:0)
I had the wrong command
Private Sub this()
DoCmd.OutputTo acOutputForm, "form name", acFormatXLS, "C:\Users\dcoats\Desktop\filename.xls"
End Sub
答案 1 :(得分:0)
基本上,就像这样........如果你的意思是数据表视图中的实际表单,你可以使用DoCmd.OutputTo方法将该表单的数据导出到Excel。
DoCmd.OutputTo acOutputForm, "frmResults", acFormatXLS, _
"C:\your_path_here\ExportedResults.xls"
但是,如果您在数据表视图中打开查询,而不是实际表单,则可以导出查询的结果集。
DoCmd.OutputTo acOutputQuery, "qryResults", acFormatXLS, _
"C:\your_path_here\ExportedResults.xls"