By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,027 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,027 IT Pros & Developers. It's quick & easy.

TransferSpreadsheet Method and SQL

P: n/a


Thanks for taking the time to read my question.

I want to use SQL in the TransferSpreadsheet Method, but I can't get it
to work.

I don't know why, because I've done a debug.pring on the same code to
see what the code resolves to and it looks just like the select
statement in the query I based it on.

I want SQL in there so that it can be dynamic. Any table, and any date
field in that table.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8,
  2. "SELECT " & Me.cboTableNames & ".*, " & Me.cboTableNames & "." &
  3. Me.cboDateFields & " " & _
  4. "FROM " &
  5. Me.cboTableNames & _
  6. "WHERE ((("
  7. & Me.cboTableNames & "." & Me.cboDateFields & ") Between #" &
  8. Me.txtStartDate & "# And #" & Me.txtEndDate & "#));", Me.txtSaveTo & "\"
  9. & Me.txtFileName
  10.  
  11.  

The error I get is: Error Number 3011, The Microsoft Jet Database Engine
could not find the object 'the sql I wrote goes in here'. Make sure the
object exists and that you spell its name and the path name correctly.

Thanks again for your help.

Brad

*** Sent via Developersdex http://www.developersdex.com ***
May 15 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Mon, 15 May 2006 17:57:40 GMT, Brad wrote:
Thanks for taking the time to read my question.

I want to use SQL in the TransferSpreadsheet Method, but I can't get it
to work.

I don't know why, because I've done a debug.pring on the same code to
see what the code resolves to and it looks just like the select
statement in the query I based it on.

I want SQL in there so that it can be dynamic. Any table, and any date
field in that table.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8,
  2.  "SELECT " & Me.cboTableNames & ".*, " & Me.cboTableNames & "." &
  3.  Me.cboDateFields & " " & _
  4.                                                               "FROM " &
  5.  Me.cboTableNames & _
  6.                                                               "WHERE ((("
  7.  & Me.cboTableNames & "." & Me.cboDateFields & ") Between #" &
  8.  Me.txtStartDate & "# And #" & Me.txtEndDate & "#));", Me.txtSaveTo & "\"
  9.  & Me.txtFileName
  10.  

The error I get is: Error Number 3011, The Microsoft Jet Database Engine
could not find the object 'the sql I wrote goes in here'. Make sure the
object exists and that you spell its name and the path name correctly.

Thanks again for your help.

Brad

*** Sent via Developersdex http://www.developersdex.com ***


i believe you must use a named database object (table or query).
Create a query, using your SQL.
Use the query name (in quotes) in place of your SQL.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
May 15 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.