Truncation of memo field in Access 2010 query

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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Rey Obrero (Capricorn1)Commented:
you can use VBA and recordset to achieve this
Liberty4allRetiredAuthor Commented:
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.
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Rey Obrero (Capricorn1)Commented:
when you export to excel, are you using an excel template?, existing excel file?
Liberty4allRetiredAuthor Commented:
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).
Rey Obrero (Capricorn1)Commented:
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")
	with xlobj
		for j=0 to rs.fields.count-1
			.range("A2").copyfromrecordset rs
	end with
end sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kelvin SparksCommented:
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.

Liberty4allRetiredAuthor Commented:

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?
Rey Obrero (Capricorn1)Commented:
you have to set the WrapText property of the cells to true

after the copyfromrecordset line, add this

Liberty4allRetiredAuthor Commented:
Perfect!  Only change needed was to the cell reference ("b2:b100") to the one containing the memo field.

Thank you very much!
Rey Obrero (Capricorn1)Commented:
pls. don't forget to close the thread
Liberty4allRetiredAuthor Commented:
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.
Liberty4allRetiredAuthor Commented:

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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.