display/hide subforms

Weresmytriple

Registered User.
Local time
Today, 23:10
Joined
Sep 5, 2013
Messages
58
hi

i have created a form with 3 subforms on. i was just wondering is it possible to display/ hide these subforms based on a Yes/No field in the form. as the subforms would only be valid if the field is ticked as yes.

thanks for any help

michael
 

Attachments

  • form.jpg
    form.jpg
    85.4 KB · Views: 79
Hello Weresmytriple, It sure is possible, BUT a word of caution to this tale. You will have empty spaces in the Form if they are hidden, might not be looking great.. Is that something you would want to go ahead with?

It might look something like..

attachment.php
 

Attachments

  • attachment.jpg
    attachment.jpg
    94.9 KB · Views: 253
yes im sure. the final display isnt important, its more important that it functions correctly. so far i have coded an on click event

Code:
Private Sub CQC_Click()
If CQC = Yes Then
        CQC_Subform.Visible = True
        Else
        CQC_Subform.Visible = False
        
End If
End Sub

however this is doing the exact opposite of what i need. it is hiding the subform when checked and unhiding it when unchecked

thanks for the help
 
Instead of Yes try True/False.. If you want it also to do when the Form is opened you might need to have the same code in the Form Current method..

Also just for the fun of it, you can do it in one single line.
Code:
Private Sub CQC_Click()
    CQC_Subform.Visible = Me.CQC
End Sub

Private Sub Form_Current()
    CQC_Subform.Visible = Me.CQC
End Sub
 
Oh forgot to say, you can add the Sub Form's in separate tabs.. This way when you Hide them you can save the bizarre gap in the Form..
 
Not tags.. taBs.. Like..

attachment.php
 

Attachments

  • tabDisplay.png
    tabDisplay.png
    13.8 KB · Views: 217
yeah sorry that was a typo. how would i go about creating the tabs? as that would be really useful.

thanks
 
You are welcome, post back if you are stuck. Good Luck. :)
 
You first create the tab in the current form then just cut the SubForm from there and put it into the tab..
 

Users who are viewing this thread

Back
Top Bottom