Results 1 to 9 of 9
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    TextBox Visible (03)

    How does one change the "visible" status of a textbox via code?

    As an example I have a combobox dropdown that if a certain item is selected than a textbox becomes visible.

    <img src=/S/whisper.gif border=0 alt=whisper width=29 height=17> I feel more comfortable doing it in Excel but don't tell anyone.

    Thanks,
    John

  2. #2
    New Lounger
    Join Date
    Jan 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: TextBox Visible (03)

    We will call the text box: TxtSuperman
    We will call the form: FrmSuperheros

    Try adding the code into the On Click event for the Combo Box:

    [forms]![FrmSuperheros]![TxtSuperman].visible = True

    You will just need to fill in the form name and the text box name in for what I have.

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: TextBox Visible (03)

    What you stated makes sense. How does one reflect in the code that if the result of the combobox = "deposit" then make the textbox invisible.

    I believe it would be something like this:
    If [forms]![FrmSuperheros]![ComboBox].Text = "deposit" then [forms]![FrmSuperheros'![TxtSuperman].visible = true

    I get hung up with the result of the combobox.

    Thanks,
    John

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TextBox Visible (03)

    Does it work if you omit .Text ?

  5. #5
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: TextBox Visible (03)

    Hans,

    It doesn't work. I believe the issue relates to the name of the combobox ie combobox name = "Type". I don't know how to express it in code.

    Thanks,
    John

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TextBox Visible (03)

    What is the 'real' version of the code you have now?

  7. #7
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: TextBox Visible (03)

    Private Sub Type_Click()
    If [Forms]![Checkbook]![ComboBox]![Type] = "Withdrawal" Then
    [Forms]![Checkbook]![Check].Visible = False
    Else
    [Forms]![Checkbook]![Check].Visible = True
    End If
    End Sub

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TextBox Visible (03)

    You should not use the word ComboBox here. Change

    [Forms]![Checkbook]![ComboBox]![Type]

    to

    [Forms]![Checkbook]![Type]

    Note: you can simply the code to

    Private Sub Type_Click()
    Me![Check].Visible = Not (Me![Type] = "WithDrawal")
    End Sub

    The keyword Me refers to the form (or report) itself.

  9. #9
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: TextBox Visible (03)

    Hans,

    The problem was related to the bound column. It was set to "1" instead of "2". Where "2" represents the words in the combobox.

    Regards,
    John

Posting Permissions

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