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.
>
>
- DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8,
-
> "SELECT " & Me.cboTableNames & ".*, " & Me.cboTableNames & "." &
-
> Me.cboDateFields & " " & _
-
> "FROM " &
-
> Me.cboTableNames & _
-
> "WHERE ((("
-
> & Me.cboTableNames & "." & Me.cboDateFields & ") Between #" &
-
> Me.txtStartDate & "# And #" & Me.txtEndDate & "#));", Me.txtSaveTo & "\"
-
> & Me.txtFileName
-
>
-
>
>
> 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