Set subform invisble from button inside subform?

CocodaMonkey

New member
Local time
Yesterday, 17:03
Joined
Oct 3, 2008
Messages
4
I've been trying for awhile to set a subform as invisible from a button within the sub form itself. I have no problem doing it from the main form but can't figure out a way to do it from the sub form. I figured it's just an issue with the sub form not being allowed to have the focus when it's set to invisible but even if I set that it still doesn't work.

I have a main form called ClientsMainfrm. The subform is called ClientAddfrm. I can add "Me.ClientAddfrm.Visible = False" to any event on the main form and it works fine. But I need to be able to hide the sub form off an event inside the sub form itself so I figured I could do something like this in the sub form.

Forms![ClientsMainfrm].SetFocus
[ClientAddfrm].Form.Visible = false

For reasons I can't comprehend this actually closes the main form and makes it exit access completely. I've also tried things like

Forms![ClientsMainfrm].SetFocus
me.form.visible = false

and had no luck. Is it possible to hide a sub form based on an event from the sub form itself?

Thanks in advance for any help you can offer.
 
setfocus to something in the parent first

then it should work
 
I've done that. I even showed it in my post. Is there some trick to doing this?
 
i think oyu need to use a specific control on the main form

parent!txtbox.setfocus

then maybe explicitly

forms!mainformname!subform.visible = false

where subform is the name of the subform on the parent form
 
Thanks that works. It seems to make a diffrence that I actually use parent rather then the name of the parent which strikes me as odd since the setfocus part seems to work either way but if I didn't use parent it crashes when I try to hide the sub form.

Thanks again
 

Users who are viewing this thread

Back
Top Bottom