Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA to export query to Excel truncates field at 255 char

Status
Not open for further replies.

ajaeger

Technical User
Feb 6, 2003
201
US
I have a query that pulls from a SQL table. It pulls a field, COMPANY_DESCRIPTION that is defined as a text field. When I look at the query results in Access, I see all the characters in that field, for example, I see 1245 characters for Company A's description. When I export it from within Access (right-click the query and export to Excel), I also see all 1245 characters for that field. However, when I export it via code, I only see the first 255 characters of that field. I'm using:


strExportAs = strPath + "\" + strCompany + ".xls"

DoCmd.SetWarnings False
DoCmd.SetWarnings False
DoCmd.TransferSpreadsheet acExport, 8, "qryExportOne", strExportAs
DoCmd.SetWarnings True


I'm using Excel 2007.

Anna Jaeger
iMIS Database Support
 
ajaeger,
I think [tt]DoCmd.OutputTo[/tt] is the easy solution since it more closely matches what your doing through the UI.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Using the following, I'm still truncating at 255:

DoCmd.OutputTo acOutputQuery, "qryExportOne", acFormatXLS, strExportAs, False, , False

Am I missing something? Is there a way to reference the saved export setup that I have in Access that exports correctly?

Thanks.

Anna Jaeger
iMIS Database Support
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top