I use this code to export a query to a folder on the desktop and it works fine with Access 2007.
I have to many issues with this in windows XP and office 2010 to get it to work.
I would rather select an external drive name, ie e or f on the parent form, and then the query must export to the selected drive. Is this possible?
The unbound combobox name on main form: "drive"
I imagine it has to do with the strPath . My link to the "drive" combobox on main form is:
Any suggestions please
I have to many issues with this in windows XP and office 2010 to get it to work.
I would rather select an external drive name, ie e or f on the parent form, and then the query must export to the selected drive. Is this possible?
The unbound combobox name on main form: "drive"
Code:
DoCmd.OpenReport "rptStocktake1", acViewPreview, "", "", acNormal
DoCmd.Minimize
Dim strUserName As String, strPath As String
Dim strReportname As String
DoCmd.Minimize
strUserName = Environ("username")
strReportname = [Forms]![home]![facility3] + "-" & Format(Date, "dd-mm-yyyy") + ".pdf"
strPath = "C:\Users\" & strUserName & "\desktop\Stocktakefiles\" & strReportname ' current path to desktop
'''strPath = "[Forms]![home]![drive]" ' path to combobox
DoCmd.OutputTo acOutputReport, "rptStocktake1", acFormatPDF, strPath, False
MsgBox "The File have been succesfully exported to your desktop folder called stocktakefiles "
DoCmd.close acReport, "rptStocktake1"
End If
Code:
[Forms]![home]![drive]
Comment