Unfortunately, there are many issues in Microsoft Access that cause ActiveX controls to lose their control source and this can effect Total Access Memo.
Fortunately, you can resolve this issue by setting the ControlSource in the form's load event. For example:
Private Sub Form_Load() tamDemo.ControlSource = "RTFField" End Sub
(where tamDemo is the name of the control, and "RTFField" is the ControlSource.) Close and re-open the form to fire the Form_Load Event, and reset the control source.
Please Note: If you are not using the code above, you must reset the control source manually any time an error occurs on the form that causes it to lose its control source.
The simplest way is to ensure the Total Access Memo control always shows the proper information on Reports is to use Total Access Memo in an UNBOUND way.
- Create a Text box on the report and set it's "Visible" property to False. Make its BackColor red so you know in design view it is an invisible control to the user.
- Set the Text box to the same Control Source that Total Access Memo is currently bound to.
- Remove the Control Source for the Total Access Memo Control.
- In the detail format event (which you are using anyhow for HeightOfText), simply add this code as one of the FIRST things done in the Detail Format:
Private SubPrivate Sub Detail_Format(Cancel As Integer, FormatCount As Integer) ' NOTE: tamDemo is the name of the Total Access Memo control ' Kill the existing Value tamDemo.Value = "" ' Reset the value to the text box value tamDemo.Value = YourNewTextBoxName End Sub
Now continue on with the rest of the detail format code (like HeightOfText)
Important Information for both Forms and Reports:
NOTE: One of the major (known) issues where a Control Source is caused to be lost, is when the application encounters an error and continues to run. MS Access is known to drop the control source for ActiveX controls when this occurs.
- Stop using "On error resume next", prevent the errors, and close the object instead of continuing on. When an error occurs, the user should close the object and re-open it. Provided you are using the code above, when the form closes and re-opens the Control Source will be restored by the code.
- The same solution recommended for Reports, will also work for Forms. The code to reset the value will be put in the On_Current event of the form and be aware that there is additional code needed to ensure the control source (text box) is properly updated with changes made to the Total Access Memo control.