Scott.Flexforce
Scott.Flexforce

Reputation: 57

Transferring a value from an object to Userform Text Box in VBA

This code below works only after a second attempt and all others after that. What can I do to allow this code to pass the value client to the Userform called Portal in Textbox1 on first attempt?

I need the info to pass from the inputbox after a correct password has been entered to the Portal userform as I need to specify several different variables and I cannot write the code for the 70+ objects that will link to the userforms through this code in assign macro.

Any help will be appreciated if anyone else has had this issue.

I have tried clearing user form inputs on workbook open but this hasn't worked.

Sub object6_Click()
    Dim Password As Variant
    Password = Application.InputBox("Enter Password Here", "Password")

    Select Case Password
        Case Is = False
            Exit Sub
        Case Is = "plenish"
            Portal.Show
            client = "plenish"
            If Portal.TextBox1.Value = "" Then
                Portal.TextBox1.Value = client
            Else
                Exit Sub
            End If
            Exit Sub
        Case Else
            MsgBox "Incorrect Password"
    End Select
End Sub

Upvotes: 1

Views: 493

Answers (1)

EvR
EvR

Reputation: 3498

Your code stops running after Portal.show

try this:

Sub object6_Click()
    Dim Password As Variant
    Password = Application.InputBox("Enter Password Here", "Password")

    Select Case Password
        Case Is = False
            Exit Sub
        Case Is = "plenish"
            client = "plenish"
            If Portal.TextBox1.Value = "" Then Portal.TextBox1.Value = client
            Portal.Show 'vbModeless
            Exit Sub
        Case Else
            MsgBox "Incorrect Password"
    End Select
End Sub

Upvotes: 1

Related Questions