Solved Show Hide sub Form (1 Viewer)

Teri Bridges

Member
Local time
Today, 00:34
Joined
Feb 21, 2022
Messages
53
I want to show/Hide my sub form. when the user clicks the button the subform displays and when they click again it hides
I cannot get any of these to work
'Hide It
Forms!frmCourseDetails!frmCourseReviewCycleSubform.Visible = False
'Show it
Forms!frmCourseDetails!frmCourseReviewCycleSubform.Visible = True

This does not work either
Private Sub btnOpenReviewCycle_Click()
If Me.frmCourseReviewCycleSubform = False Then

Me.frmCourseReviewCycleSubform = True

ElseIf Me.frmCourseReviewCycleSubform = True Then

Me.frmCourseReviewCycleSubform = False

End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:34
Joined
May 7, 2009
Messages
16,775
maybe try:
Code:
Private Sub btnOpenReviewCycle_Click()
With Me!frmCourseReviewCycleSubform.Form
   .Visible = Not .Visible
End With
End Sub
 

Teri Bridges

Member
Local time
Today, 00:34
Joined
Feb 21, 2022
Messages
53
Tried that and get the same error
1651294713928.png

1651294732461.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:34
Joined
May 7, 2009
Messages
16,775
you bring your main form in design view.
click on the subform in question and see it's Name on the Property window.
substitute the "Real Name" to frmCourseReviewCylemSubform in your code.
 

Teri Bridges

Member
Local time
Today, 00:34
Joined
Feb 21, 2022
Messages
53
you bring your main form in design view.
click on the subform in question and see it's Name on the Property window.
substitute the "Real Name" to frmCourseReviewCylemSubform in your code.
Yes I checked that.
1651296848310.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:34
Joined
May 7, 2009
Messages
16,775
ok, you got it.
but on the snapshot you showed, it is not the Caption i am refering.
if you go to the "Other" tab, and you will see it's Name property.
 

Teri Bridges

Member
Local time
Today, 00:34
Joined
Feb 21, 2022
Messages
53
ok, you got it.
but on the snapshot you showed, it is not the Caption i am refering.
if you go to the "Other" tab, and you will see it's Name property.
Humm. I do not see that on the other tab.
1651300160327.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:34
Joined
May 7, 2009
Messages
16,775
try it again. click anywhere the form but the subform.
now try clicking on the Border of the subform, until a Yellow-Orange line/Box surrounds it.
go and see it's Name on the property sheet.
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:34
Joined
Sep 21, 2011
Messages
10,838
I would have thought you would need to use the name of the subform control? That is the same name as the form when you add the subform, which you have just done?
 

Teri Bridges

Member
Local time
Today, 00:34
Joined
Feb 21, 2022
Messages
53
I would have thought you would need to use the name of the subform control? That is the same name as the form when you add the subform, which you have just done?
I had eariler changed the name of the form and thought I had updated it everywhere. But I did not know about the other tab check. I am sure that is why I was getting the code errors. When I deleted the sub form and added it back (New Name) it worked. These are my rookie mistakes.
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:34
Joined
Sep 21, 2011
Messages
10,838
I always prefixed the subform control name with sfrm, so as to be able to distinguish between control and form, once I found this out.
Same with subreport, srpt
 

Teri Bridges

Member
Local time
Today, 00:34
Joined
Feb 21, 2022
Messages
53
I always prefixed the subform control name with sfrm, so as to be able to distinguish between control and form, once I found this out.
Same with subreport, srpt
Good Idea. I have been adding subform to the end but using the "s" would shorten things up and make sorted. Thanks.
 

Users who are viewing this thread

Top Bottom