473,414 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

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 ***
May 15 '06 #1
1 3966
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: O'Donnell Tribunal | last post by:
Hello Everybody, I am using the TransferSpreadsheet method to import spreadsheets for processing. say my code looks like this: DoCmd.TransferSpreadsheet acImport, 0, _ "tbltempImport1", ""...
0
by: Mick Hardy | last post by:
Hi, Has anyone seen this weird behaviour or have any suggestions or can anyone reproduce it? The history: I converted a large third party DB from 97 to XP and it uses the...
1
by: Bob Hynes | last post by:
Hi All, In Access97 I'm using a TransferSpreadsheet acExport in vba code and it errors when the spreadsheet I'm exporting does not exist. If I create a empty spreadsheet with the name I use in the...
1
by: barma16 | last post by:
I've hit a bit of a brick wall here, and could use some advice. I have an Access application whose output is a four-tab Excel spreadsheet where three of the four tabs are the result of database...
3
by: user_5701 | last post by:
Hello, I'm getting an error with a Docmd.Transferspreadsheet line of code: DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel2000, "tblTest", pathAndFilename, True The above line...
4
by: Google Boy of Company C | last post by:
Hi Does anyone know why there seems to be a file name limit of 60 characters in Transferspreadsheet. I am exporting some records and this is giving me severe grief. I keep getting a message...
13
by: aleksandra_83 | last post by:
Hello, I have searched all over google groups and internet, but I have not found a solution to this problem that has worked. The solutions I found helped me single out the line that is causing...
2
by: DeanL | last post by:
Hey Guys, Does anyone know of a way to format the output of the TransferSpreadsheet method in Access 97 so that the exported spreadsheet has some formatting (column widths, row heights, cell...
3
by: Icarus | last post by:
I'm using TransferSpreadsheet to import an Excel file in to MS Access 2003. DoCmd.TransferSpreadsheet acImport, 8, strTable, strFileName, True, "" One of the columns in the Excel file is a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.