OnClick Visible = False on SubForm

N

NYCMoreOn

OKay, I have been beating my head up against the wall for the past 4
days trying to get this to work... I have a form with a subform
(default is hidden), the idea is to be able to browse a resource
database OR, should you choose, search the database by criteria you
set. When you hit the "Search Resources" button on the main form, the
subform becomes visible. I got this to work fine use the following:

Private Sub Search_Resources_Click()
Me!SearchForm.Visible = Not Me!SearchForm.Visible
End Sub

With the subform visible a user can define his criteria and hit
submit...fine. However, I ahve built a command button on the subform
to allow the user to exit out if he/she decides they do not want to
search - essentially hiding the subform again.

The problem I'm having is finding the right code to make a subform
invisible from a command button ON the subform itself.

I know I'm overlooking something totally simple. Can someone please
point me in the right direction. Thanx
 
A

Allen Browne

Try setting focus to another control on the main form first, so you can hide
the subform control on the main form:
Me.Parent.[SomeOtherControl].SetFocus
Me.Parent.SearchForm.Visible = False
 
N

NYCMoreOn

Tahdah! Thank you so much!
I knew it was something small. I had tried setting the focus to the
main form itself but it didn't work. However, if I set the focus to
the Search_Resources command button on the main form it worked like a
charm.

Thanks again.
 
Top