Solved

Truncation of memo field in Access 2010 query

Posted on 2014-11-13
13
704 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access module into  a teradata procedure or db2 procedure 18 81
How to get data off Lotus Notes server 4 67
access vba 5 55
Intermittent OleDbConnection Error 20 51
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

732 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