on click event - subform visible or no

  • Thread starter Thread starter Opal
  • Start date Start date
O

Opal

I'm trying to use an on click event to
switch back and forth from one
subform to another.

The command button is on each subform
and I am using the following:

Dim blnVisible As Boolean

blnVisible = Not Me.Parent!subfrmZoneOrg1.Visible

Me.Parent!subfrmZoneOrg1.Visible = blnVisible

Me.Parent!subfrmZoneOrg1.SetFocus
Me.Parent!subfrmZoneOrg1Final.Visible = False

The problem I am having has to do with setting
the focus. I keep getting an error that says

"Microsoft Office Access can't move the focus to
the control subfrmZoneOrg1"

But if I comment out the line:

Me.Parent!subfrmZoneOrg1.SetFocus

I get an error that says:

"You can't hide a control that has the focus"

How can I accomplish this?
 
Opal said:
I'm trying to use an on click event to
switch back and forth from one
subform to another.

The command button is on each subform
and I am using the following:

Dim blnVisible As Boolean

blnVisible = Not Me.Parent!subfrmZoneOrg1.Visible

Me.Parent!subfrmZoneOrg1.Visible = blnVisible

Me.Parent!subfrmZoneOrg1.SetFocus
Me.Parent!subfrmZoneOrg1Final.Visible = False


You need to make the other subform visible, then give it the
focus before making the current subform invisible.

I think the subfrmZoneOrg1 subform's code should be like:
Parent.subfrmZoneOrg1.Visible = True
Parent.subfrmZoneOrg1.SetFocus
Parent.subfrmZoneOrg1Final.Visible = False
 
Back
Top