ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   text boxes retaining their last value on form close and restart (https://www.excelbanter.com/excel-discussion-misc-queries/235509-text-boxes-retaining-their-last-value-form-close-restart.html)

NDBC

text boxes retaining their last value on form close and restart
 
In my user form there are 5 text boxes. Rider1 through Rider5. Is there a way
to store the values of these text boxes so the last values come up as the
starting values if the user accidently closes down the form (x in top right)
and then clicks the button to restart it.

Thanks

Jacob Skaria

text boxes retaining their last value on form close and restart
 
Insert a module and declare variables to store these values which will remain
untl the user close the workbook.

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

In my user form there are 5 text boxes. Rider1 through Rider5. Is there a way
to store the values of these text boxes so the last values come up as the
starting values if the user accidently closes down the form (x in top right)
and then clicks the button to restart it.

Thanks


Jacob Skaria

text boxes retaining their last value on form close and restar
 
If you are new to VBA/programming; from VBAProject Explorer right click the
userform icon. Insert Module and declare your vairables as below

Public strTextBox1 As Variant
Public strTextBox2 As Variant
Public strTextBox3 As Variant

-----------------------------------------------------------------------------
In userform code store the values on terminate and reassign on activate

Private Sub UserForm_Activate()
Rider1.Text = strTextBox1
Rider2.Text = strTextBox2
Rider3.Text = strTextBox3
End Sub

Private Sub UserForm_Terminate()
strTextBox1 = Rider1.Text
strTextBox2 = Rider2.Text
strTextBox3 = Rider3.Text
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Insert a module and declare variables to store these values which will remain
untl the user close the workbook.

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

In my user form there are 5 text boxes. Rider1 through Rider5. Is there a way
to store the values of these text boxes so the last values come up as the
starting values if the user accidently closes down the form (x in top right)
and then clicks the button to restart it.

Thanks


Dave Peterson

text boxes retaining their last value on form close and restart
 
It sounds like you've assigned a cell to the ControlSource property for the
textboxes.

You may find it easier to drop that technique and use the OK button to update
the cells with the values from the textboxes.

And you can use the _initialize procedure to populate the textboxes with the
values from the cells:

Option Explicit
Private Sub UserForm_Initialize()
Me.TextBox1.Value = Worksheets("Sheet1").Range("A1").Text
End Sub



NDBC wrote:

In my user form there are 5 text boxes. Rider1 through Rider5. Is there a way
to store the values of these text boxes so the last values come up as the
starting values if the user accidently closes down the form (x in top right)
and then clicks the button to restart it.

Thanks


--

Dave Peterson


All times are GMT +1. The time now is 10:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com