I am trying to make 2 subfroms alternate from being visible when a click a
button on one or the other. Using the following code--- Me.visible = False
--- Access says I can't hide a control that has the focus
When I sucessfuly move the focus to the other subform or main form and type:
subfrom1.visible = false Access says it can't find the control I am refering
to.
Access doesn't seem to have an easy way of refering to its subforms?
Ken Snell [MVP] - 21 Jan 2005 16:52 GMT
You must use the name of the subform control (the control that holds the
subform) when you want to make the subform invisible.
Me.SubformControlName.Form.Visible = False
Note that SubformControlName may or may not be the same as the name of the
Source Object (the form that serves as the subform).
While in design view, click on the very top of the subform and then read its
name from the Other tab of the Properties window.

Signature
Ken Snell
<MS ACCESS MVP>
>I am trying to make 2 subfroms alternate from being visible when a click a
> button on one or the other. Using the following code--- Me.visible =
[quoted text clipped - 8 lines]
>
> Access doesn't seem to have an easy way of refering to its subforms?
Dirk Goldgar - 21 Jan 2005 16:57 GMT
> I am trying to make 2 subfroms alternate from being visible when a
> click a button on one or the other. Using the following code---
[quoted text clipped - 6 lines]
>
> Access doesn't seem to have an easy way of refering to its subforms?
It does, but you don't know it. <g>
On Subform1, the code to make Subform2 visible and hide Subform1 would
look like this:
With Me.Parent.Subform2
.Visible = True
.SetFocus
End With
Me.Visible = False
You have to make the other subform visible before you can set focus to
it, and you have to set the focus away from the active subform before
you can hide it.

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Dirk Goldgar - 21 Jan 2005 17:04 GMT
> I am trying to make 2 subfroms alternate from being visible when a
> click a button on one or the other. Using the following code---
> Me.visible = False --- Access says I can't hide a control that has
> the focus
It occurs to me that one simple way to swap the visibilty of subforms is
to put each subform on a different page of a tab control, and then just
change pages on the tab control (which you can do programmatically by
assigning the PageIndex of the page you want to show to the Value
property of the tab control). If you don't want the user to be able to
change pages manually, you can set the tab control up with its Style
property set to None (no tabs or buttons)/

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)