on click event - subform visible or no

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?
 
M

Marshall Barton

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
 

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