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

Last reviewed: August 29, 1997
Article ID: Q163350
The information in this article applies to:
  • Microsoft Access 7.0

SYMPTOMS

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

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.

  1. Open the sample database Northwind.mdb.

  2. Open the Employees form in Design view.

  3. 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
    
    

  4. 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" (without the quotation marks).

  5. Close the Employees form. Do not save changes if you want to leave the Northwind sample database unchanged.

STATUS

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

MORE INFORMATION

Steps to Reproduce Problem

  1. Repeat steps 1 and 2 of the "Resolution" section.

  2. 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
    
    

  3. 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.

  4. Close the Employees form. Do not save changes if you want to leave the Northwind sample database unchanged.
Keywords          : kbusage PgmHowTo
Version           : 7.0
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbbug
Solution Type     : kbworkaround


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.