+ Reply to Thread
Results 1 to 7 of 7

Can user form fields be depenent upon the answer to another field?

Hybrid View

  1. #1
    Registered User
    Join Date
    02-19-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2013
    Posts
    69

    Can user form fields be depenent upon the answer to another field?

    I'm making a user form with multiple checkboxes. I'd like to have a text box pop up only if the checkbox is checked. Is that possible?

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,336

    Re: Can user form fields be depenent upon the answer to another field?

    Hi Alicia,

    See the attached with some simple code that does what I think you want.
    Private Sub CheckBox1_Click()
     If Me.CheckBox1.Value = True Then
            Me.TextBox1.Visible = False
        Else
            Me.TextBox1.Visible = True
        End If
    End Sub
    CheckBox show TextBox if clicked.xlsm
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    02-19-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2013
    Posts
    69

    Re: Can user form fields be depenent upon the answer to another field?

    Thanks
    * for you both

  4. #4
    Registered User
    Join Date
    02-19-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2013
    Posts
    69

    Re: Can user form fields be depenent upon the answer to another field?

    OMG nevermind. I forgot to change Visible to False

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Can user form fields be depenent upon the answer to another field?

    Probable just use the value of the checkbox,

    Private Sub CheckBox1_Click()
        x = Me.CheckBox1.Value
        Me.TextBox1.Visible = x
    End Sub
    Or even

    Private Sub CheckBox1_Click()
        Me.TextBox1.Visible = Me.CheckBox1.Value
    End Sub

  6. #6
    Registered User
    Join Date
    02-19-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2013
    Posts
    69

    Re: Can user form fields be depenent upon the answer to another field?

    I've used all 3 of these and they all work, however, when the user form opens all of the text fields are visible. Only once the box is checked and then unchecked the text field becomes hidden. How can I adjust this to hide the text fields when the user form opens?

  7. #7
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Can user form fields be depenent upon the answer to another field?

    In initialize code
    Me.TextBox1.Visible = False
    Me.TextBox2.Visible = False
    Me.TextBox3.Visible = False
    etc

    OR

    Dim ctrl As Control 
    For Each ctrl In Me.Controls 
    
     If TypeOf ctrl Is msforms.TextBox Then 
     ctrl.Visible = False 
     End If 
    
    Next
    Last edited by nigelog; 09-20-2017 at 09:33 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Creating a User Form Template with Dynamic fields
    By squidpop in forum Excel General
    Replies: 1
    Last Post: 01-23-2016, 03:21 PM
  2. [SOLVED] User Form Required Fields
    By hhpack3 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-01-2014, 04:32 PM
  3. User Form Date fields error out
    By Turtle2 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-21-2013, 09:17 PM
  4. User form which having some fields to be entered only once.
    By Kiran2012 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-26-2012, 08:36 AM
  5. How to Display All the fields into User Form When selecting any row
    By angeld27 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2011, 04:37 AM
  6. Filling form fields via worksheet dropdowns, user update via form, change form color
    By Demosthenes&Locke in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2010, 08:58 AM
  7. Best way to fill user form fields
    By evanzo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-23-2008, 09:41 PM

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