Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old May 15th, 2006, 07:05 PM
Brad
Guest
 
Posts: n/a
Default TransferSpreadsheet Method and SQL



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 ***
  #2  
Old May 15th, 2006, 11:35 PM
fredg
Guest
 
Posts: n/a
Default Re: TransferSpreadsheet Method and SQL

On Mon, 15 May 2006 17:57:40 GMT, Brad wrote:
[color=blue]
> 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 ***[/color]

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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,338 network members.