This article was previously published under Q294286
Advanced: Requires expert coding, interoperability, and multiuser skills.
For a Microsoft Access 97 version of this article, see 182302.
For a Microsoft Access 2000 version of this article, see 208801.
When you output a report to Microsoft Excel, any Memo field is truncatedto 255 characters. You may also see this behavior when you click theAnalyze It with Microsoft Excel command while you are previewing a report.
In Excel, the maximum length of text-cell contents is 32,000 characters. However, Access outputs a report to Excel 5.0/95 format, in which the maximum length of text-cell contents is 255.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
Export the underlying table or query to Excel 2000 file format. To do this, follow these steps:
In the Database window, select the table or query on which the report is based.
On the File menu, click Export.
In the Export Table '<Table Name>' dialog box, select Microsoft Excel 97-2002 (*.xls) from the Save as Type box.
Click Export All to export the table.
Create text boxes on the report to split the Memo field into 250-characterstrings. After you have output the report, reassemble those strings.
For example, assume you have a Memo field that is named Notes, and in some records, the contents of that field is 700 characters long. You can create three text boxes in the report with each of the following three expressions as the control source for one of the text boxes:
After you have output the report to a spreadsheet, you can reassemble thesegments of the Memo field. For example, the segments of the Memo field ofthe first record appear in cells B2, C2, and D2 respectively. You canreassemble the Memo field by typing the following formula in another cell,E2:
You can then copy this formula to the rest of the cells in column E toreassemble the Notes field for all of the records.
Note that the CONCATENATE function returns the error #VALUE when you try to use the formula
The address of every cell whose contents you want to include in theconcatenated result must be listed separately.
If the length of the data in the Memo field makes it necessary for you tocreate more than a few text boxes, you can use a Visual Basic forApplications procedure to automate the creation of those text boxes. Thefollowing example demonstrates how to use a procedure to create the textboxes, to output the report, and then to reassemble the contents of the text box.
Follow steps 1 through 7 in the "Steps to reproduce behavior" sectionlater in this article.
Create a new report in Design view that is based on the tblMemoOutput table.
Drag the ID field to the detail section of the report.
Save the report as rptMemoOutput. Keep the report open in Design view.
Open a new module, and then type the following procedure:
Function MemoSplitter(strReportName As String, _ strFieldName As String, lngMemoLength As Long) Dim NewControl As Control Dim intLoopCount As Integer For intLoopCount = 0 To lngMemoLength / 250 Set NewControl = CreateReportControl(strReportName, _ acTextBox, acDetail) NewControl.Name = intLoopCount & "MemoText" NewControl.ControlSource = "=Mid([" & _ strFieldName & "]," & 250 * intLoopCount + 1 _ & ",250)" Next intLoopCountEnd Function
Compile and then save the module as mdlSplitFunction.
Type the following line in the Immediate window, and then press ENTER:
View the report in print preview, and note the three IDs: a, b, and c. On the Tools menu, point to Office Links, and then click Analyze It with Microsoft Excel.
When the data appears in a spreadsheet file in Microsoft Excel, click cell A1, and then press CTRL+SHIFT+END to select all of the data.
On the Format menu, point to Row, and then click Autofit.
Select cell A2. On the Insert menu, click Rows.
Type the following formula in cell A2:
Copy the formula to cells B2 through U2.
Select cells A2 through U2.
On the Edit menu, click Copy.
On the Edit menu, click Paste Special.
Under Paste in the Paste Special dialog box, click Values, and then click OK. This converts the formulas in the second row to values, which you can use to sort the segments of the Notes field.
Click cell A2, and then press CTRL+SHIFT+END to select all but the first row of data.
On the Data menu, click Sort.
In the Sort dialog box, click Options.
Under Orientation in the Sort Options dialog box, click Sort Left To Right, and then click OK.
In the Sort dialog box, click Row2 in the Sort By list, and then click OK to sort the segments of the Notes field.
Copy the formula to cells W4 and W5 to reassemble the Notes field for each record.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Steps to reproduce the behavior
Start Microsoft Access, and then open any database.
Create the following table:
Table: tblMemoOutput -------------------- Field Name: ID Data Type: Text Field Name: Notes Data Type: Memo
Save the table as tblMemoOutput. When you are prompted to create a primary key, click No.
Open the table in Datasheet view, and then enter the following records:
ID Notes -- ----- a a b b c c
Open a new module, and then type the following procedure:
Function FillMemo(strTableName As String, _ strFieldName As String) Dim db As Database Dim rs As Recordset Dim intLoopCount As Integer Set db = CurrentDb Set rs = db.OpenRecordset(strTableName) Do Until rs.EOF rs.Edit For intLoopCount = 1 To 26 rs(strFieldName) = rs(strFieldName) _ & String(200, Chr(intLoopCount + 64)) Next intLoopCount rs.Update rs.MoveNext Loop db.CloseEnd Function
Compile and then save the module as mdlDataFunction.
Enter the following line in the Immediate window, and then press ENTER:
Use the AutoReport: Columnar Wizard to create a report that is based on tblMemoOutput. View the report in Print Preview.
On the Tools menu, point to Office Links, and then click Analyze It With Microsoft Excel.
When the data appears in a spreadsheet file in Microsoft Excel, type the following formula into cell C2:
Note that the data in the Notes field has been truncated to 255characters.
For more information about loading the output of a report into Microsoft Excel, click Microsoft Access Help on the Help menu, type outputting data in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.