Solved

Truncation of memo field in Access 2010 query

Posted on 2014-11-13
13
545 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 119

Expert Comment

by:Rey Obrero
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
 
LVL 119

Expert Comment

by:Rey Obrero
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 119

Accepted Solution

by:
Rey Obrero 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 119

Assisted Solution

by:Rey Obrero
Rey Obrero 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 119

Expert Comment

by:Rey Obrero
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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 …

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now