Results 1 to 2 of 2
  1. #1
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156

    Hide text untill click of a button

    I have an unusual question. I am making a small riddle data base for a boy that is in hospital. It will keep his mind bust during his hospital stay. I want to hide the text to the answer and it only be viewable when the I give up button. My idea is to have a form with the riddle and a sub form with the text of the answer. But the answer text cannot be seen until the I give up button is pushed. I have the form with the sub form created but I have no idea how to hide the text of the answer until the button is clicked. I am using Access 2016.



    Thank-you and happy holidays

    Cheeco

  2. #2
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    I figured it out. Now the below information also work with access 2016.

    APPLIES TO: ACCESS2007, 2010 (UNTESTED IN EARLIER VERSIONS)
    The following tutorialshows you how you can use VBA to hide a form field in an access form followingthe update of a text box or after the click of a button and how to make itvisible again.
    For this tutorial you willneed to create the following fields /controls on your Access form:
    A text box called“textbox1” (the box that will be updated)
    A text box called“textbox2” (the box that will be hidden)
    A command button Called“btnVisible”
    1. Select the text box
    2. In the tools section ofthe “Design” tab click on the item called “Property Sheet”
    3. Select the “Event” tab
    4. On the “After Update”property click on the little black down arrow / triangle and select “EventProcedure”
    5. Click on the three dotsnext to the little black down arrow / triangle – this will open up the VBAwindow and you should see the following:
    Private Subtextbox1_AfterUpdate()
    End Sub
    6. On a new line directlybetween the two lines above add the following
    Me.textbox2.Visible= False
    7. Go back to your form andselect the command button called “btnVisible”
    8. In the tools section ofthe “Design” tab click on the item called “Property Sheet” and select the“Event” tab
    9. On the “On Click”property click on the little black down arrow / triangle and select “EventProcedure”
    10. Click on the three dotsnext to the little black down arrow / triangle – this will open up the VBAwindow and you should see the following:
    Private SubbtnVisible_Click()
    End Sub
    11. On a new line directlybetween the two lines above add the following
    Me.textbox2.visible= True
    Save your changes and testyour form / report
    Note: The text boxwill only be hidden once the user has finished entering data and clicked awayfrom the field.
    You can adapt the aboveoption in many ways to hide or make visible any controls on your form.
    If you want a field to behidden when the form first loads do the following:
    2.1 Select the field youwant to be hidden when the form loads
    2.2 In the tools section ofthe “Design” tab click on the item called “Property Sheet” and select the“Format” tab
    3.2 Change the “Visible”property to “No”
    Save your changes and testyour form / report


Please reply to this thread with any new information or opinions.

Similar Threads

  1. Show & Hide Text Box with a Button
    By aamer in forum Access
    Replies: 3
    Last Post: 07-30-2016, 09:40 PM
  2. Replies: 9
    Last Post: 03-31-2015, 04:13 PM
  3. Replies: 2
    Last Post: 09-11-2014, 11:37 PM
  4. Replies: 1
    Last Post: 07-18-2011, 03:08 AM
  5. Making a toggle button hide a text box.
    By RemonKoybito in forum Forms
    Replies: 3
    Last Post: 05-20-2011, 11:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums