Solved

Truncation of memo field in Access 2010 query

Posted on 2014-11-13
13
647 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

820 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