Solved

Truncation of memo field in Access 2010 query

Posted on 2014-11-13
13
616 Views
Last Modified: 2014-11-20
When I run a select query in Access 2010 the output for a memo field truncates at 255 characters.  I'm guessing this is normal based on various sources.  My query does not contain any aggregate functions (no group by and no expressions).  The property settings for the query are all blank so nothing appears to be suspect there.  The problem is the output results need to be exported to Excel, and since the memo column is not fully populated in the query, the result in Excel is also incomplete.

If I change my query to create a table and export or copy that to Excel, the problem does not exist.  However, for certain projects this means having to create multiple temporary tables and then deleting them.  If someone can suggest a way to modifying the query to have the full contents of the memo field appear, if possible, that would save some time and be much appreciated.
0
Comment
Question by:Liberty4all
  • 6
  • 5
  • 2
13 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 40441541
The method that you describe of using temporary tables is the accepted solution. I have not seen any other solution to this known problem.


Kelvin
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40441544
you can use VBA and recordset to achieve this
0
 

Author Comment

by:Liberty4all
ID: 40441552
If the code is not too lengthy I might try it.  My queries are simple and don't want to make them more complex than necessary.  If you can please post the code I will look at it and determine if the time it takes to make it work is less than what I'm currently doing.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40441568
when you export to excel, are you using an excel template?, existing excel file?
0
 

Author Comment

by:Liberty4all
ID: 40441576
I don't use an Excel template or an existing file.  I create a new Excel file and then add individual worksheets for multiple exports into it (populated by pasting).
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40441588
place this codes in a regular module
change table names, etc accordingly
sub export2Excel()

dim xlObj as object, j as integer
dim rs as dao.recordset, sql as string

sql="Select * from tablex"

set rs=currentdb.openrecordset(sql)

set xlObj=createobject("excel.application")
	xlobj.workbooks.add
	
	with xlobj
		.worksheets(1).activate
		for j=0 to rs.fields.count-1
			.cells(1,j+1).value=rs(j).name
		next
			.range("A2").copyfromrecordset rs
	end with
	
	xlObj.quit
end sub

Open in new window

0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 40441592
You also need to treat this approach with caution. I have found through experience at times, Excel (not Access) will truncate data in some cells to 1024 characters. - seems to happen when a larger number of rows are being returned, or where a lot of columns are involved.


Kelvin
0
 

Author Comment

by:Liberty4all
ID: 40441664
Rey,

The code runs and exports the Access table to Excel as expected.  The only problem is the column for the memo field essentially overwrites two columns to the right of it with data.  The column headings for the two fields to the right of the memo field appear but only the contents of the memo field appear in them in certain cases.  Those two columns contain numeric data.  Some of them are blank and, if so, the contents of the memo field populates them depending on the amount of text.  This does not happen when the length of the text string in the memo column is shorter.

The result is confusing for users and thus will not work.  I cannot post the actual results due to confidentiality but will attempt to describe how it appears in the attached file.  The third row in the attached file is the desired result but only appears when the length of the memo text string is relatively short.

If I expand the Memo column the contents still appear in the next two columns.  Expanding the two numeric columns doesn't solve the problem.  Can you suggest a way to fix this?
Memo-Column-Overflow.docx
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 500 total points
ID: 40441697
you have to set the WrapText property of the cells to true

after the copyfromrecordset line, add this

.range("b2:b100").wraptext=true
0
 

Author Comment

by:Liberty4all
ID: 40441736
Perfect!  Only change needed was to the cell reference ("b2:b100") to the one containing the memo field.

Thank you very much!
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40441900
pls. don't forget to close the thread
0
 

Author Closing Comment

by:Liberty4all
ID: 40456039
Please note the comments from Kelvin Sparks regarding Excel (not Access) will truncate data in some cells to 1024 characters.  I have not confirmed this can occur using the code above but mention it so others are aware of it as a possibility.
0
 

Author Comment

by:Liberty4all
ID: 40456063
Rey,

I had difficulty closing the thread until now.  I switched from using Internet Explorer 8 to Chrome and that allowed my selection of solutions, points, and grade to finally be accepted.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question