473,769 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error while Exporting To Excel From MS Access

31 New Member
I am exporting the data from ms access to excel where the error displays as Run-time error -2147467259(8000 04005)

Method 'Copyfromrecord set' of object 'Range' faild.
Ws.Range("A2"). CopyFromRecords et rs

One of my Field Name, DATATYPE is set to MEMO

I am testing with DATATYPE As TEXT and the Characters within 255 then the report get's downloaded to Excel, if the DATATYPE is set to MEMO and the characters are more than 255 error dispalys as explained above.

.......iam using the below code
Expand|Select|Wrap|Line Numbers
  1. .
  2.   Dim strmsg As String
  3.   Dim DB As Database
  4.   Dim Qd As QueryDef
  5.   Dim rs As Recordset
  6.   Dim Ws As Object
  7.   Dim i As Integer
  8.   Dim FirstDate As String
  9.   Dim LastDate As String
  10.   Dim Status As String
  11.   Dim mypath As String
  12.   Dim WB As Workbook
  13.  
  14.  
  15.     Set DB = CurrentDb()
  16.     Set Qd = DB.QueryDefs("Database Reports Query")
  17.  
  18.     Set rs = Qd.OpenRecordset()
  19.  
  20.     Set WB = Workbooks.Add
  21.     Set Ws = Sheets("Sheet1")
  22.     Range("A1").Select
  23.  
  24.     For i = 0 To rs.Fields.Count - 1
  25.     Ws.Cells(1, i + 1).Value = rs.Fields(i).Name
  26.  
  27.     Next
  28.  
  29.     Ws.Range(Ws.Cells(1, 1), Ws.Cells(1, rs.Fields.Count)).Font.Bold = True
  30.     Ws.Range("A2").CopyFromRecordset rs
  31.  
  32.     Sheets("Sheet1").Select
  33.     Range("A1").Select
  34.     Selection.CurrentRegion.Select
  35.     Selection.Columns.AutoFit
  36.     Range("A1").Select
  37.  
  38.     Me.cboStartDate.Value = ""
  39.     Me.cboEndDate.Value = ""
  40.     Me.Status_Reports_up_to_date.Value = ""
  41.  
  42.         strmsg = strmsg & "Report downloaded successfully...!!!"
  43.         If MsgBox(strmsg, vbOKOnly, "Reports!") = vbOK Then
  44.         End If
  45.  
  46.   WB.Close
  47.   Qd.Close
  48.   rs.Close
  49.   DB.Close
---------------------

Kindly help me....
Ananth
Sep 6 '08 #1
3 2543
NeoPa
32,573 Recognized Expert Moderator MVP
I'm afraid that the answer is almost certainly that it cannot handle memo fields of length >255.

I think you probably already suspected that, but I can't give you any better news :(
Sep 6 '08 #2
Tempalli
31 New Member
Memo fields in Access are accepting more than 255 characters but when it downloads to Excel using the above code... Error displaying as mentioned above.

Kindly help.

Ananth
Sep 9 '08 #3
NeoPa
32,573 Recognized Expert Moderator MVP
I do understand the problem Ananth, I am simply saying that it is a limitation. Memo fields are limited in so many ways.

Having just run a test with a simple Export though, I can say this transfers the data across ok.

I may get some spare time later to try out a version of your code (We are not a code-fixing service by the way) to see if the .CopyFromRecord set() function has this built-in restriction. Having checked your code visually though, other than assuming that this function would handle this when maybe it doesn't, there seems to be nothing wrong with the effective part of it.

PS. Please do not vent your frustration by shouting (posting in all caps). This is not allowed on this site for fairly obvious reasons, and repetition will surely trigger an official site warning. -Administrator.
Sep 9 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
9248
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works only exporting to single worksheet. but i need to export data to multiple worksheets. it is very urgent to us. so please help me in code.
4
3949
by: D | last post by:
I've created a report with many subreports of aggregate data. I want my client to be able to export this data to Excel to make her charts, etc. Only one problem: one of the fields is a "SchoolYear" TEXT field that contains data such as 2000/01, 2001/02, etc. If I export a Query with this kind of data to Excel, it gives me the text value of this field; however, when I export a Report bound to this TEXT field, Excel gives me the values 36526,...
2
7711
by: G | last post by:
When I export data from access to excel by with "export" or "Analyze with" I seem to loose parts of some fields (long text strings). Is there a way to export it all to excel? Thanks G
1
3167
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream As System.IO.MemoryStream = 3 myReport.ExportToStream( ExportFormatType.PortableDocFormat) 4 Response.Clear() 5 Response.Buffer() = True
21
6243
by: bobh | last post by:
Hi All, In Access97 I have a table that's greater than 65k records and I'm looking for a VBA way to export the records to Excel. Anyone have vba code to export from access to excel and have the code use multiple excel tabs within a workbook???? Anyone have vba code that would create a temp table write 65,000 records to it, export those to excel, clean the temp table, append the next 65,000 records, export it to excel with a different...
1
7621
by: John Overton | last post by:
I have a new requirement to Import and Export Excel tables into and out of Access 2003. The Excel tables are located on a remote server but I know the path to the Excel Files. Can you please help me with the Access VBA code I need to perform these Importing and Exporting tasks?? Sincerely, John Overton
3
2512
by: jennwilson | last post by:
Access 2000 - I have developed a database that houses patient information. The patient information must be sent in an excel file to another company department. I know how to export my data to Excel where it ends up in individual cells (Rows/Colums, etc). I would like for the report that I am exporting to Excel to transfer like a pdf. file. and be similar to the report generated in the database. Kind of like a snapshot of the report, is this...
2
1812
by: accessvbanewbie | last post by:
I keep getting an error stating OBJECT VARIABLE OR WITH BLOCK VARIABLE NOT SET. This error just recently began to happen. I am exporting some records to excel into a preformatted report. The records are exported successfully but this error pops up before the export is completed. When I run the debugger this line gives the error message(OBJECT VARIABLE OR WITH BLOCK VARIABLE NOT SET) If Not (rsSchedules.EOF = True) Then Below is my...
5
5896
geolemon
by: geolemon | last post by:
Import text wizard says: I'm banging my head on this one, here's why: I've been importing files using this process and data format, with success! I created a temporary table in Access to facilitate my import process (It's all text columns, I perform transformations later). And I created a template in Excel to correspond to the table - essentially it's just column headers: In Excel, I've been opening files of work that we've done...
0
9583
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10039
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9860
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8869
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6668
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3955
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.