=> Hiding a SubForm

  • Thread starter Thread starter Rhonda Fischer
  • Start date Start date
R

Rhonda Fischer

Hello,

My subform is dependant on values entered by the user,
so I only want to make it visible after values entered.

How do I hide a subform and then unhide it on the click
of a command button. I found on trying to use the
following code that the subform was not recognised as
being opened so could not set attribute to hidden.

call HideAForm("[Forms]!frmOrderSheet!frmOrderSheetSub")

Sub HideAForm(myform As String)
'Close form if open so that it can be hidden
if currentProject.AllForms(myForm).IsLoaded = True then
DoCmd.Close acForm, myform
end if
Application.SetHiddenattribute acForm, myform True
End Sub

and then I used the following to make the subform visible
neither bits of code work?

Call UnhideAForm([Forms]!frmOrderSheet!frmOrderSheetSub")

Sub UnhideAForm(myForm as String)
If Application.GetHiddenAttribute(acForm, myForm) = True
then
Application.SetHiddenAttribute acForm, myForm, False
DoCmd.OpenForm myForm
end if
end sub

Any ideas on how I can hide my subform?

Thank you very much, I'm sure I've made it more complicated
than need be.

Cheerio
Rhonda
 
Try:

Forms!MainForm.SubformControl.Visible = False

to hide it. Set the above to True if you want to show the Subform. Note
that the name of the Subform*Control* may be different from the name of the
Form you use as the Subform.

If you run the code in the context of the MainForm, you can use:

Me.SubformControl.Visible = ...
 
To hide the subform without hiding the main form, toggle the Visible
property of the subform control:

With Forms!frmOrderSheet!frmOrderSheetSub
.Visible = Not .Visible
End With
 
Back
Top