Hi all.
I have an (odd) question;
The code: DoCmd.OutputTo acOutputQuery, sql_File, "Excel Workbook (*.xlsx)", , True
Works like a charm when using a predefined query in Access, named sql_File.
But, I would like to hardcode the string inside a form module and set up as sql-string based on several situations
Why doesn't this work - I always getting the 3011 error (cannot find the items in sql string - nor fields or table):
Dim tmpSqlStr As String
tmpSqlStr = "SELECT * FROM dbo_11_Area"
DoCmd.OutputTo acOutputQuery, tmpSqlStr, "Excel Workbook (*.xlsx)", , True
I've tried all combination of quotes, brackets etc around the tmpSqlStr, with or without the dbo_ in table name without any luck.
The Sql String in the variable tmpSqlStr are stripped down to a minimum, but still can't get it to work. I believe there is a tiny detail - but I can't see it...
The BE is an std. sql-server (hence dbo_)
I really hope someone have smart fix for this
Best regards,
Geirr
I have an (odd) question;
The code: DoCmd.OutputTo acOutputQuery, sql_File, "Excel Workbook (*.xlsx)", , True
Works like a charm when using a predefined query in Access, named sql_File.
But, I would like to hardcode the string inside a form module and set up as sql-string based on several situations
Why doesn't this work - I always getting the 3011 error (cannot find the items in sql string - nor fields or table):
Dim tmpSqlStr As String
tmpSqlStr = "SELECT * FROM dbo_11_Area"
DoCmd.OutputTo acOutputQuery, tmpSqlStr, "Excel Workbook (*.xlsx)", , True
I've tried all combination of quotes, brackets etc around the tmpSqlStr, with or without the dbo_ in table name without any luck.
The Sql String in the variable tmpSqlStr are stripped down to a minimum, but still can't get it to work. I believe there is a tiny detail - but I can't see it...
The BE is an std. sql-server (hence dbo_)
I really hope someone have smart fix for this
Best regards,
Geirr