473,549 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export to excel truncates to 255 chars...

Shakss2
19 New Member
Hi...

I am exporting some data from a table with a memo field to excel but the excel report truncates the memo field data to 255 chars.
Expand|Select|Wrap|Line Numbers
  1. Dim strPath As String
  2.     ' Current path
  3.     strPath = CurrentProject.Path & "\Adhoc_Report.xls"
  4.     'New workbook object
  5.     Dim sh As Workbook
  6.     DoCmd.OutputTo acOutputTable, "test2", acSpreadsheetTypeExcel9, strPath, 1
  7.     'Setting obj
  8.     Set sh = CreateObject(strPath)
  9.     'sh.ActiveSheet.Cells.EntireColumn.AutoFit
  10.     sh.ActiveSheet.Cells.ColumnWidth = 23
  11.     sh.ActiveSheet.Cells.EntireRow.AutoFit
Please help...

Thanks
Shaq
Feb 21 '08 #1
5 10283
Stewart Ross
2,545 Recognized Expert Moderator Specialist
...I am exporting some data from a table with a memo field to excel but the excel report truncates the memo field data to 255 chars.
Hi. Excel text is a maximum of 255 chars (like an Access string). What is in your memo field, and is it frequently more than 255 characters long? You could split the memo data into multiple text fields in your export query, each no more than 255 characters long, but this will look messy in the Excel sheet. All depends on what you use that memo field for...

-Stewart
Feb 21 '08 #2
Shakss2
19 New Member
Hi...

Thanks for ur reply.
The memo field has all text data in it & it is often more than 255 chars.

If u could help me with some code which U have suggested than it will be of great help.

As a beginner im not sure if I answered ur Q's.

Thanks again.

Shaq
Feb 22 '08 #3
Stewart Ross
2,545 Recognized Expert Moderator Specialist
...The memo field has all text data in it & it is often more than 255 chars.
Hi again Shaq. In the circumstances (and against my better judgment!) the simplest solution I can think of is a brute-force one of adding additional fields that split up your memo field into a series of sub-fields, each of no more than 255 characters. It's not elegant at all, but it would allow you to retain the simple Excel export you currently use. Perhaps other contributors will be able to suggest better ways...

Although you have mentioned that the memo field is more than 255 characters you haven't said how long it is in typical use. You can use the Len() string function to find out, if you are at all familiar with using functions in queries.

In the DoCmd line of your code the exported table is called test2. If this is a query you can add new columns beside your memo field to split up the contents of your memo. If test2 is a table then you need to start by creating a query based on test2 so that you can add the additional memo fields. Include all the fields that are currently in test2.

Assuming that your memo is no more than 4x255 characters long (1020 chars), open the query in design view and add three blank columns beside your memo field. Add the following field names in the three blank columns, in the rows marked field: substituting the name of your current memo field in each case:

Memo Pt 2: Mid$(Nz([name of memo field]), 256, 255)
Memo Pt 3: Mid$(Nz([name of memo field]), 511, 255)
Memo Pt 4: Mid$(Nz([name of memo field]), 766, 255)

The mid$ (mid-string) function in each of these will extract 255 characters from your memo field at positions 256, 511, 766 respectively. Nz() ensures that if the field is null Mid$ is still fed by a string (although zero-length). Mid$ does not fail if there are no characters to return - it just returns a zero-length string.

If you added the three columns to a new query based on test2 save it under a suitable name (such as qryTest2) then change your Docmd statement to refer to qryTest2 instead of test2.

These are the only changes you will need to make to at least be able to export more of your memo field in this brute-force way. If however you need more characters still I think a very different solution will be required - because it is not really appropriate to go on taking 255 character chunks out of your memo field just because that is Excel's text limit.

-Stewart

ps if you are working in SQL view you can add the following to your select statement to do the same job as adding the three columns above:
Expand|Select|Wrap|Line Numbers
  1.  
  2. select ..., [name of memo field], Mid$(Nz([name of memo field]), 256, 255) as [Memo Pt 2], Mid$(Nz([name of memo field]), 511, 255) as [Memo Pt 3], Mid$(Nz([name of memo field]), 766, 255) as [Memo Pt 4], ...
  3.  
Feb 22 '08 #4
missinglinq
3,532 Recognized Expert Specialist
What kind of information does this memo field hold and why are you exporting it to Excel? Excel is pretty much used exclusively to manipulate data (read "crunch numbers") and the one thing that is absolutely verboden is in Access is the storing of data in memo fields that will ever, in any way, shape or form, need to be manipulated.

Maybe we can come up with a better solution.

Linq ;0)>
Feb 22 '08 #5
Shakss2
19 New Member
Hi...

Thanks a lot for helping and apologies on replying so late.

Your logic worked... Thank U all for the help.

This is what i did:
lsttest_criteri a = lsttest_criteri a & "," & "Forecast_Train ing AS Training_Inform ation" & ""
lsttest_criteri a = lsttest_criteri a & "," & " Mid(Nz(Forecast _Training),256, 255) as T1 " & ""
lsttest_criteri a = lsttest_criteri a & "," & " Mid(Nz(Forecast _Training),512, 255) as T2 " & ""
lsttest_criteri a = lsttest_criteri a & "," & " Mid(Nz(Forecast _Training),768, 255) as T3 " & ""

The used the below code to concatinate the data in 4 cells to 1 and then delete the other 3 cells

lrows = sh.ActiveSheet. UsedRange.Rows. COUNT


For i = 1 To 256
If Trim(sh.ActiveS heet.Cells(1, i)) = "Training_Infor mation" Then
For J = 2 To lrows
sh.ActiveSheet. Cells(J, i) = Trim(sh.ActiveS heet.Cells(J, i)) & Trim(sh.ActiveS heet.Cells(J, i + 1)) & Trim(sh.ActiveS heet.Cells(J, i + 2)) & Trim(sh.ActiveS heet.Cells(J, i + 3))

Next J

sh.ActiveSheet. Columns(i + 1).Delete
sh.ActiveSheet. Columns(i + 1).Delete
sh.ActiveSheet. Columns(i + 1).Delete

Exit For
End If
Next

Shaq
Mar 4 '08 #6

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

Similar topics

1
5014
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table. Before I iterate through the recordset I instruct the browser that the content type is Excel using the following line: (Response.ContentType =...
8
13208
by: Taffman | last post by:
I've searched this goup for an answer to this, there are many discussions that come close but non that I can find that actually addresses this particular problem. I'm exporting queries to Excel. These queries have memo fields in them Each memo field is trunkated, i.e cuts off after 255 characters. Is there any way either via VBA or...
13
13190
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel" HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=ABC.xls") HttpContext.Current.Response.Write(strHTML) HttpContext.Current.Response.End() However when the user tries to...
5
31896
by: Simon | last post by:
Dear reader, With the export command you can export a query to Excel. By activate this command a form pop's up with the following text:
1
9757
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm having I'd be most appreciative. The database is already constructed, I'm just wanting to export the data to an excel file. In short, I'm hoping...
5
2565
by: =?Utf-8?B?TGFtaXM=?= | last post by:
Hello, I have a dataset that has information written in Swedish language, that means alot of stranch chars like 'Å, Ä, Ö' etc and my code void Export(datagrid myDataGrid){ Response.Clear(); Response.AddHeader("content-disposition","attachment;filename=FileName.xls"); Response.Charset = "";...
2
3622
by: mccalla | last post by:
Hi, I am very new to MS Access. I have inherited an existing app which was done in MS Access 2003. In this app, there is a report which contains a memo field. There are no formats, functions, unions, or anything. It is populated from a simple select. The problem is....when the user exports the report to excel, it seems to be truncating this...
1
1109
by: Reggie | last post by:
Hi and TIA! I'm exporting a dataset/datgrid to excel but some text fields get converted to numbers in excel and I loose leading zero's. I've tried several methods with no success. If anyone has come across this and can point me in the right direction I would appreciate it. Thanks! -- ****************** Reggie
2
6394
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the method.... it creates 6 sheets # region Namespaces using System;
0
7477
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...
0
7750
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. ...
0
7991
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...
1
7509
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5118
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...
0
3524
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1971
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
1
1084
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
790
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...

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.