+ Reply to Thread
Results 1 to 3 of 3

VBA userform Textbox visible = true

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    VBA userform Textbox visible = true

    Hi

    I have a cbox that has for numbers 601,602,603,604 and on the exit event a textbox will display the text that matches the number with a Vlookup formula.

    That all works fine...

    Now i have added another textbox which is not visble and should only be visible = true if the code in the cbox is 601.

    Below is the code i have however even if i select 601 the txtbox does not become visible. there must be a problem with my wording?

    Private Sub cBDcode_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    If Me.cBDcode = "" Then
    Exit Sub
    
    Else
    If Me.cBDcode.ListIndex = -1 Then 'Check if the value is matching the criteria
            MsgBox "Incorrect Breakdown Code!" & vbCrLf & "Please Select from the Dropdown list?" _
            , vbOKOnly + vbExclamation, "Breakdown Code Error!!"
            Me.cBDcode.Text = vbNullString
            Exit Sub
         End If
        End If
    If cBDcode > "" Then
      txtKPI.Value = WorksheetFunction.VLookup(CLng(cBDcode.Value), Range("Fix"), 2, 0)
    If (cBDcode.Value) = "601" Then
    txtJobNumber.Visible = True And Label11.Visible = True
      Call unlock_update
      End If
      End If
    End Sub
    Please help???
    Last edited by vlady; 11-28-2012 at 02:32 AM. Reason: code tags

  2. #2
    Valued Forum Contributor
    Join Date
    11-02-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    564

    Re: VBA userform Textbox visible = true

    Try putting textbox visible code in cbox change event.

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA userform Textbox visible = true

    your And part is incorrect-it's actually just doing a bit wise comparison
    If cBDcode.Value = "601" Then
    txtJobNumber.Visible = True
    Label11.Visible = True
      Call unlock_update
      End If
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1