Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving entries in a textbox

Status
Not open for further replies.

jrobin5881

Technical User
Mar 10, 2004
228
US
I'm missing something. I have a userform with a series of textboxes for my end users to input information. I then have the "Save As" dialog box to save the workbook open when the user has completed the form. My "expectation" is that the data entered into the text boxes will remain there when the user saves the file to their local drive, but that is not happeining when I test it.

Do I have to save the entry to each box to a variable on the userform and save it that way BEFORE saving the workbook? I hope not. That'll be a ton of coding as I have 26 textboxes on some of the userforms. I"m sure it must be something small that I"m missing.
 



Hi,

Controls are not persistant.

Put the values on a sheet somewhere.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Yes, if you want the data to be persistent between each time the form is run, you will have to save the data yourself. The data (and any variables used in the userForm) is not retained when the form is unloaded. You will need to save the data somewhere into the workbook if you want to use it when the form is run again.
 
Okay, will do. I'll move them to another sheet. Thanks guy's
 


Here's a little unload routine. You could do something similar when you load the form...
Code:
Private Sub UserForm_Terminate()
    Dim ctl As Control, lRow As Long
    With Sheet1  'Sheet1 can be hidden
        .cells.clearcontents
        lRow = 1
        For Each ctl In UserForm1.Controls
            Select Case Left(ctl.Name, 4)
                Case "Text"
                    .Cells(lRow, 1).Value = ctl.Name
                    .Cells(lRow, 2).Value = ctl.Text
            End Select
            lRow = lRow + 1
        Next
    End With
End Sub

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top