Hide/Unhide subform

Lamb2087

Registered User.
Local time
Today, 15:53
Joined
Feb 7, 2003
Messages
103
I would like to hide and unhide a subform with the click of a command button. Can I create command button thru a wizard and change the code to do this?
me.hide.subform name

me.unhide.subform name
 
Lamb,

Putting code like this behind command buttons will hide and unhide a subform:
Code:
'Hide It
Forms!FrmMainName!FrmSubName.Visible = False

'Show it
Forms!FrmMainName!FrmSubName.Visible = True

Regards,
Tim
 
Hide/Unhide

Here is the code in the command button I used.

Private Sub CmdHide_Click()
Forms!XXXXX!TrialCadetAdd.Visible = False

End Sub


MainForm XXXXX
SubForm TrialCadetAdd

I get an error stating that It could not find the expression
Trial Cadet Add
I changed the subform name as a form from Trial Cadet Add
to TrialCadetAdd

Any suggestions to make this work?
 
Try this

Private Sub CmdHide_Click()

Me.TrialCadetAdd.Form.Visible = False

End Sub
 
Hide/Unhide

Can I do this so if you click on the command button the form disappears and if you click on it again it appears?



Private Sub CmdHide_Click()
Forms!XXXXX!TrialCadetAdd.Visible = False

Forms!XXXXX!TrialCadetAdd.Visible = True

End Sub
 
No - you need to have an If statement.

Private Sub CmdHide_Click()
If Me.TrialCadetAdd.Visible = False Then

Me.TrialCadetAdd.Visible = True

ElseIf Me.TrialCadetAdd.Visible = True Then

Me.TrialCadetAdd.Visible = False

End Sub

You need to cater for all options

Col
:cool:
 
I want to hide my subform until the user clicks the button
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
 
Wow a 19 year old thread.
That has to be the record surely? :-)
 
Also a thread where @ColinEssex answered an Access question....! Never seen that before.

@Teri Bridges
Please create a new thread for your question so it gets more attention.
 
Also a thread where @ColinEssex answered an Access question....!
Over the 23 years posting here, I have answered many access problems. I don't do it now as I'm retired and well into my 70's, I'm afraid the memory is failing, along with eyesight, hip joints and heart. Probably within 5 years I'll not be posting at all, unless they have WiFi in hell.
Col
 
for one line of code so the button hides or shows

Code:
Me.sfrmMySubformName.Visible =not Me.sfrmMySubformName.Visible

although you might want some additional code to change the button caption

Code:
Me.sfrmMySubformName.caption=iif(Me.sfrmMySubformName.Visible,"Hide Subform","Show subform")

or shorter code

Code:
with Me.sfrmMySubformName
    .visible=not .visible
    .caption=iif(.Visible,"Hide Subform","Show subform")
end with
 

Users who are viewing this thread

Back
Top Bottom