retrieving data from multiple textboxes created du

2019-08-16 00:37发布

Okay...so I got some great help resolving my issue with adding multiple labels and textboxes to an Excel userform during runtime using vba. Now, the issue is I'm trying to retrieve data from those dynamically created textboxes. It's not that I can't get the data, it's that I can't pull it out of the form and use it once the form is closed.

I used the following code sets for retrieving data from a single option textbox and it works perfectly:

Private Sub SOSubmitButton_Click()
    FLNAmt = SingleOptionForm.SOBox
    Unload SingleOptionForm
End Sub

and

SingleOptionForm.Show
SingleOptionForm.Hide

When I use FLNAmt shortly after hiding the form, there's data in the variable. However, using some of the much similar coding:

Private Sub AsgnFLNButton_Click()
    Dim MultFLNAmt As String
    Dim i As Integer
    i = 1
    If i = 1 Then
        MultFLNAmt = MultipleOptionForm.Controls("Textbox" & i)
    Else
        MultFLNAmt = MultFLNAmt & "," & MultipleOptionForm.Controls("Textbox" & i)
    End If

    Unload MultipleOptionForm
End Sub

and

MultipleOptionForm.Show    
MultipleOptionForm.Hide

MsgBox MultFLNAmt

When the MsgBox appears, MultFLNAmt is blank. Is there something different I need to do when gathering data from dynamically created textboxes and using it after the form closes than I do when using a textbox already hard coded into the form?

0条回答
登录 后发表回答