Hello
I have a form with three txtboxes to query between dates, one to select Date1, other to select Date2, and another to type the value of a code.
When exporting the file I need the file name as indicated in line "sExcelWB=.... dd_mm_yyyy_plot_qry_task.xls
This is the code:
With this form, I need to export the query to Excel and to create a chart.
Again as in former question in this Forum I VBA Editor displays an execution ERROR this time ERROR 3011. I have been, trying for hours to fix this error.
I am really confused by this Execution Errors.
I really appreciate if anyone can help me.
I have a form with three txtboxes to query between dates, one to select Date1, other to select Date2, and another to type the value of a code.
When exporting the file I need the file name as indicated in line "sExcelWB=.... dd_mm_yyyy_plot_qry_task.xls
This is the code:
Code:
Sub cmdTransfer_Click()
Dim sExcelWB As String
Dim xl As Object ''Excel.Application
Dim wb As Object ''Excel.Workbook
Dim ws As Object ''Excel.Worksheet
Dim ch As Object ''Excel.Chart
Dim myRange As Object
Set xl = CreateObject("excel.application")
sExcelWB = "D:\testing\" & Replace(Me.txttask_from, "/", "_") & " - " & Replace(Me.txttask_to, "/", "_") & "_" & Replace(Me.txttask_plot, "/", "_") & "_qry_task.xls"
'This will overwrite any previous run of this query to this workbook
'I coloured on yellow the code line showing ERROR 3011
[COLOR="Yellow"]DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, sExcelWB, True[/COLOR]
Set wb = xl.Workbooks.Open(sExcelWB)
'Sheets are named with the Access query name
Set ws = wb.Sheets("qry_task")
Set ch = xl.Charts.Add
ch.ChartType = xlColumnClustered
xl.Visible = True
xl.UserControl = True
End Sub
With this form, I need to export the query to Excel and to create a chart.
Again as in former question in this Forum I VBA Editor displays an execution ERROR this time ERROR 3011. I have been, trying for hours to fix this error.
I am really confused by this Execution Errors.

I really appreciate if anyone can help me.