Hide a command button when a form/subform opens

G

Guest

I've created a form with a subform in Microsoft Access. I want to hide a
command button which runs a macro procedure from the subform and stop
appearing in the main form.

Here's the procedure about the command button in the subform:

Private Sub Cerrar_ISA_Click()
Dim stDocName As String

stDocName = "cerrar ISA"
DoCmd.RunMacro stDocName

Exit_Cerrar_ISA_Click:
Exit Sub
End Sub

This command button runs a macro which close the subform, opens the previous
menu and restore it to it's normal size. This subform acts like a form in the
other part of my database and I make the buttons visible for use.

How do I create the procedure on making this command button not visible in
the main form which is connected the subform? How can I do this without
affecting the subform when it's used as a form? Any help would be appreciated.
 
T

Tim Ferguson

Also I would like to know how to hide a label from the subform too, so
it won't appear on the main form.

If you want to know you to address a control on a subform, you need to go
via the Form property of the subform control, like this:

Me.Controls("MySubFormControl").Form.Controls("MyLabelControl").Visible

This can be shortened to

Me!MySubFormControl.Form!MyLabelControl.Visible

but I find it easier to debug the first one.

Hope that helps


Tim F
 
G

Guest

An error appears in my main form, which is named "Almacén", saying that it
can't find "Impact Safety Analysis subform", which in this case is the
subform that is connected to the "Almacén" main form.

Like I just said I want to hide the command button and label of a subform
from stop appearing in my main form when it opens. Cerrar ISA is the name of
the command button I want to hide, and Lable178 is the name of my label.

Here's what I wrote in:


Private Sub Form_Open(Cancel As Integer)

Me!Impact_Safety_Analysis_subform.Form!Cerrar_ISA.Visible

End Sub


Any help or suggestion for this would be great.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top