ACC95: Can't Update a Memo Field Using Visual Basic Code
ID: Q163350
|
The information in this article applies to:
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.
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
- Repeat steps 1 and 2 of the "Resolution" section.
- 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
- 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.
- Close the Employees form. Do not save changes if you want to leave the
Northwind sample database unchanged.
Additional query words:
Keywords : kbusage AccCon
Version : WINDOWS:7.0
Platform : WINDOWS
Issue type : kbbug