Results 1 to 6 of 6

Thread: [RESOLVED] Hide/Unhide Access Subform

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Long Island, NY.
    Posts
    353

    Resolved [RESOLVED] Hide/Unhide Access Subform

    I have a subform on a form that I want to be hidden when the form loads and when the user clicks a command button to unhide.

    Whats the best way to do this?

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Hide/Unhide Access Subform

    In the _Load event of the main form set the Visible property of the subform to False, then in the _Click event of the CommandButton set the Visible property to True.
    Heres an example from one of my apps with a Subform called "QUOTE_DETAIL_ADD".

    VB Code:
    1. Private Sub Form_Load()
    2.     Me.txtQUOTE_DATE = Now()
    3.     Me.QUOTE_DETAIL_ADD.Visible = False
    4. End Sub
    5.  
    6. Private Sub btnAddQuote_Click()
    7.     Me.QUOTE_DETAIL_ADD.Visible = True
    8.     Me.QUOTE_DETAIL_ADD.SetFocus
    9. End Sub
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Long Island, NY.
    Posts
    353

    Re: Hide/Unhide Access Subform

    Thanks! Worked perfectly!

  4. #4
    Registered User
    Join Date
    Jun 2017
    Posts
    2

    Re: Hide/Unhide Access Subform

    Pls help me i am in trouble
    this code not work properly

    Private Sub Active_AfterUpdate()
    'After Update of checkbox1
    'Check if Active checkbox1 is selected
    'then show or hide subform
    If Me.Active = True Then
    Me.sub_form.Visible = True
    Else
    Me.sub_form.Visible = False
    End If
    End Sub

    Private Sub Form_Current()
    'On current event of main form
    'Check if Active checkbox is selected
    'then show or hide subform
    If Me.Active = True Then
    Me.sub_form.Visible = True
    Else
    Me.sub_form.Visible = False
    End If
    End Sub

    Private Sub sub_form_Enter()

    End Sub

  5. #5
    Registered User
    Join Date
    Jun 2017
    Posts
    2

    Lightbulb Re: [RESOLVED] Hide/Unhide Access Subform

    not work properly


    Private Sub Active_AfterUpdate()
    'After Update of checkbox1 ..........................ckeckbox name
    'Check if Active checkbox1 is selected
    'then show or hide subform
    If Me.Active = True Then
    Me.sub_form.Visible = True.............subform name
    Else
    Me.sub_form.Visible = False
    End If
    End Sub

    Private Sub Form_Current()
    'On current event of main form
    'Check if Active checkbox is selected
    'then show or hide subform
    If Me.Active = True Then
    Me.sub_form.Visible = True
    Else
    Me.sub_form.Visible = False
    End If
    End Sub

    Private Sub sub_form_Enter()

    End Sub

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [RESOLVED] Hide/Unhide Access Subform

    i have no idea what is not working correctly, but you can try like

    Code:
    Private Sub Active_AfterUpdate()
    'After Update of checkbox1 ..........................ckeckbox name
    'Check if Active checkbox1 is selected
    'then show or hide subform
    
      Me.sub_form.Visible = Me.Active
    
    End Sub
    you probably need to post more information about what is not working correctly

    also you should have started a new thread, not have resurrected a thread more than 10 years old
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width