Results 1 to 3 of 3
  1. #1
    RapidFireGT is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    1

    Check-box to hide/show input fields

    I’m trying to use a check-box to show/hide several input fields on a form. The names of the objects are:


    • Check-box: CustomerCheckBox
    • Input 1 field: customer_first_name
    • Input 2 field: customer_last_name
    • Input 3 field: customer_phone




    According to my Google searching, I have the proper code and I’ve tried entering it into the check-box’s events After Update and On Click, and I’ve also tried adding the code to the form’s On Current event. Here is the code I’ve used in all 3 places (it’s the same code repeated):

    Code:
    Private Sub CustomerCheckBox_AfterUpdate()
    
    
      Me.customer_first_name.Visible = (Me.CustomerCheckBox = True)
      Me.customer_last_name.Visible = (Me.CustomerCheckBox = True)
      Me.customer_phone.Visible = (Me.CustomerCheckBox = True)
    
    
      End Sub
    Code:
    Private Sub CustomerCheckBox_Click()
    
    
      Me.customer_first_name.Visible = (Me.CustomerCheckBox = True)
      Me.customer_last_name.Visible = (Me.CustomerCheckBox = True)
      Me.customer_phone.Visible = (Me.CustomerCheckBox = True)
    
    
      End Sub
    Code:
    Private Sub Form_Current()
    
    
      Me.customer_first_name.Visible = (Me.CustomerCheckBox = True)
      Me.customer_last_name.Visible = (Me.CustomerCheckBox = True)
      Me.customer_phone.Visible = (Me.CustomerCheckBox = True)
    
    
      End Sub
    Strange thing is, this code worked just fine when I created a brand new blank database and tried using a check-box to show/hide a label on a form.

    Code:
    Private Sub Check1_Click()
    
    Me.Label0.Visible = (Me.Check1)
    
    End Sub
    Any ideas why it’s not working in my populated database/form?

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    If it isn't working from the After Update event, you should

    1. make a copy of the database file first before step 2 (just in case something goes wrong)
    2. Decompile the database file.
    (see here for how: http://www.granite.ab.ca/access/decompile.htm )

  3. #3
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Or...

    you can simplify the code:

    (OnClick)
    If checkbox=true then
    customer.visible=true
    else
    customer.visible=false
    end if

    repeat for each text box

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

Similar Threads

  1. Show/Hide Form
    By sparlaman in forum Forms
    Replies: 5
    Last Post: 05-16-2011, 11:48 AM
  2. Replies: 1
    Last Post: 03-30-2011, 02:29 PM
  3. Hide and show tekstbox
    By Patience in forum Access
    Replies: 3
    Last Post: 06-18-2010, 06:15 AM
  4. hide text box till you un-tick check box
    By islandboy in forum Access
    Replies: 14
    Last Post: 09-06-2009, 10:08 AM
  5. Show Hide Subreport / acViewReport
    By BigBear in forum Reports
    Replies: 4
    Last Post: 03-30-2009, 06:07 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