Microsoft KB Archive/163350

= ACC95: Can't Update a Memo Field Using Visual Basic Code =

Article ID: 163350

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 95 Standard Edition

-



This article was previously published under Q163350



Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
When you create a form based on a table that contains a Memo field, you cannot use Visual Basic for Applications code to update text in the Memo field.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access for Windows 95" manual.



CAUSE
This behavior only occurs if you update the Memo field on the form (either manually or with code), and then you try to set the value of the Memo field in code before you save or undo the previous change.

NOTE: This behavior only occurs with Memo fields.



RESOLUTION
Before you update the Memo field in your code, use the DoMenuItem method to select or save the record as the following example demonstrates.

CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.  Open the sample database Northwind.mdb. Open the Employees form in Design view.  Place a command button on the form, set its Name property to Button0, and set its OnClick property to the following event procedure: Private Sub Button0_Click DoCmd.DoMenuItem acFormBar, acEditMenu, acSelectRecord,, _ acMenuVer70 Me![Notes] = "Testing 123" End Sub  Open the form in Form View and type any value into the Notes field, and then click the Command button. Note that the Notes Memo field displays

Testing 123

 Close the Employees form. Do not save changes if you want to leave the Northwind sample database unchanged.</ol>

<div class="status_section">

STATUS
Microsoft has confirmed this to be a problem in Microsoft Access 7.0. This problem no longer occurs in Microsoft Access 97.

<div class="moreinformation_section">

Steps to Reproduce Problem
<ol> Repeat steps 1 and 2 of the "Resolution" section.</li>  Place a command button on the form, set its Name property to Button0, and set its OnClick property to the following event procedure: Private Sub Button0_Click Me![Notes] = "Testing 123" End Sub </li> Open the form in Form View, type any value into the Notes field, and then click the command button. Note that the value of the Notes Memo field does not change because the record has not been saved.</li> Close the Employees form. Do not save changes if you want to leave the Northwind sample database unchanged.</li></ol>

Keywords: kbbug kbprogramming kbusage KB163350

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.