Thank you very much Graham, it works.
Text and Value are not the same
Quote:
The Text property returns the formatted string. The Text property may be different than the Value property for a text box control. The Text property is the current contents of the control. The Value property is the saved value of the text box control. The Text property is always current while the control has the focus.
The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name.
TextBox.Value property (Access) | Microsoft Docs
|
For the record, I had to change the userform slightly for the macros to work.
TextBox = True is replaced with TextBox <> ""
Code:
Option Explicit
Private Sub CommandButton1_Click()
Dim tmp As String
Debug.Print TextBox1Before.Text
If TextBox1.Text <> "" And TextBox1.Text <> TextBox1Before.Text Then
Debug.Print TextBox1.Text
WriteBk2 "TextBox1", TextBox1.Text
TextBox1Before.Text = TextBox1.Text
End If
If TextBox2.Text <> "" And TextBox2.Text <> TextBox2Before.Text Then
WriteBk2 "TextBox2", TextBox2.Text
TextBox2Before.Text = TextBox2.Text
End If
If TextBox3.Text <> "" And TextBox3.Text <> TextBox3Before.Text Then
WriteBk2 "TextBox3", TextBox3.Text
TextBox3Before.Text = TextBox3.Text
End If
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim tmp As String
tmp = ReadBk("TextBox1")
TextBox1.Text = tmp
TextBox1Before.Text = tmp
tmp = ReadBk("TextBox2")
TextBox2.Text = tmp
TextBox2Before.Text = tmp
tmp = ReadBk("TextBox3")
TextBox3.Text = tmp
TextBox3Before.Text = tmp
End Sub