hide control?

M

micfly

Is there a way to hide a control when a form opens? The form is a subform
that opens with an on click event.
The control I want to hide is a command button cmdSearch on form
FrmTracking. Here's the code I have so far with the exclusion, of course to
hide the control:

Private Sub cmdOpenTracking_Click()

' Opens the form FrmTracking in the Subform control, the name of the subform
is SbFrmCtl
Me.SbFrmCtl.SourceObject = "FrmTracking"

' Same as setting DataEntry to Yes in the forms property/data tab
Me.SbFrmCtl.Form.DataEntry = True

' Set the focus to the first txtbox on the subform
Me.SbFrmCtl.SetFocus

Me.SbFrmCtl.Form.NavigationButtons = False

End Sub

Thanks again for any help!
 
D

Douglas J. Steele

Set its Visible property to False. Note that the control in question cannot
have focus when you do this.
 
M

micfly

Thanks for the quick reply. There are times when this same form is opened
that I do want the control visible, hence the dilemma.
That's why I was hoping there was a way to do this in the On Click event.
 
M

Mickey Flynn

That's what I was hoping for but I don't know how to do that. Can you give
me an example here? Where would the code go and what would it look like?
Remember this is opening as a subform. Also, forgot to mention this is
Access97. Thanks again for helping.
 
D

Douglas J. Steele

So cmdSearch is the name of a control on the form being used as a subform,
and the name of the subform control is SbFrmCtl? (The name of the form being
used as the subform is irrelevant)

Me.SbFrmCtl.Form.sbFrmCtl.Visible = False


You might find http://www.mvps.org/access/forms/frm0031.htm at "The Access
Web" a useful reference.
 
M

micfly

You da man! Got it, that was taking me forever ;-(

Me.SbFrmCtl.Form.cmdSearch.Visible = False

worked. Thank you very much!
 

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