Cannot find a reference to Run-time error 3422 (Cannot modify table structure. Another user has the table open.)
Here is my code:
Function Create_Chart()
Dim dbs As Database
Dim xlApp As Excel.Application
Dim xlWorkbook As Excel.Workbook
Dim xlChartObj As Excel.Chart
Dim xlSourceRange As Excel.Range
Dim xlColPoint As Excel.Point
On Error GoTo Err_CreateChart
Set dbs = CurrentDb()
theAccessQuery = "sqry CANCELLATIONS by HOUR subform"
QueryName = "sqry CANCELLATIONS by HOUR CHART AccQry01"
NoQueries = dbs.QueryDefs.Count
For I = 0 To NoQueries - 1
If dbs.QueryDefs(I).Name = QueryName Then
DoCmd.DeleteObject acQuery, QueryName
Exit For
End If
Next I
dbs.CreateQueryDef QueryName, _
"SELECT [HOUR],[VOL by ZIP] " & _
"FROM [sqry CANCELLATIONS by HOUR subform];"
theExcelFile = "C:\TEMP\AccQry01.xls"
DoCmd.TransferSpreadsheet acExport, _
acSpreadsheetTypeExcel9, QueryName, _
theExcelFile, False
The code crashes at the "DoCmd..." line.
Can anyone help? Thanks.
Here is my code:
Function Create_Chart()
Dim dbs As Database
Dim xlApp As Excel.Application
Dim xlWorkbook As Excel.Workbook
Dim xlChartObj As Excel.Chart
Dim xlSourceRange As Excel.Range
Dim xlColPoint As Excel.Point
On Error GoTo Err_CreateChart
Set dbs = CurrentDb()
theAccessQuery = "sqry CANCELLATIONS by HOUR subform"
QueryName = "sqry CANCELLATIONS by HOUR CHART AccQry01"
NoQueries = dbs.QueryDefs.Count
For I = 0 To NoQueries - 1
If dbs.QueryDefs(I).Name = QueryName Then
DoCmd.DeleteObject acQuery, QueryName
Exit For
End If
Next I
dbs.CreateQueryDef QueryName, _
"SELECT [HOUR],[VOL by ZIP] " & _
"FROM [sqry CANCELLATIONS by HOUR subform];"
theExcelFile = "C:\TEMP\AccQry01.xls"
DoCmd.TransferSpreadsheet acExport, _
acSpreadsheetTypeExcel9, QueryName, _
theExcelFile, False
The code crashes at the "DoCmd..." line.
Can anyone help? Thanks.