Hide tab issues with focus......

J

JimiiZ

Access 2003, Windows XP
I have never had problems with Focus and making items .visible = False. have
a tab control that I want to hide at times but get an error that it still has
focus. I transfer focus to main form combo box first but it still gives me
the error. I used conditional formatting to change background colors to
yellow when they have focus so I know the focus is in the main form but still
get error 2165 You cant hide a control that has focus......

Then I tried to use the Got Focus event for the combo_box

Private Sub C_Type_GotFocus()
[Form_F CostWorks].Network_Users.Visible = False
End Sub

I still get the 2165 You cant hide a control that has focus......

Any thoughts, this is killing me........
 
M

Marshall Barton

JimiiZ said:
Access 2003, Windows XP
I have never had problems with Focus and making items .visible = False. have
a tab control that I want to hide at times but get an error that it still has
focus. I transfer focus to main form combo box first but it still gives me
the error. I used conditional formatting to change background colors to
yellow when they have focus so I know the focus is in the main form but still
get error 2165 You cant hide a control that has focus......

Then I tried to use the Got Focus event for the combo_box

Private Sub C_Type_GotFocus()
[Form_F CostWorks].Network_Users.Visible = False
End Sub

I still get the 2165 You cant hide a control that has focus......


I think the phrase in the message, "control that has focus",
is misleading. IMO, they should have said "the active
control" and there is almost always an active control on
every form.

Think about it, what is the form supposed to display when
you hide the active tab page? What should Access do when
the active control becomes invisible? If you make a
different tab page and a different control in the subform
active, the problem should not occur.
 
J

JimiiZ via AccessMonster.com

I actually have multiple tabs and the other one will hide no problem because
it does not have focus. This is tied to a clear form button and everything
is being reset. The subforms become visible depending on user choices....I
guess you could say its a sequence of events and Im having trouble stopping
it like once in a while I come across a transaction error (not in this
database though).

Inevitably an outcome of being a hacker and poor coding....heck at least im
honest ;-)

Marshall said:
Access 2003, Windows XP
I have never had problems with Focus and making items .visible = False. have
[quoted text clipped - 11 lines]
I still get the 2165 You cant hide a control that has focus......

I think the phrase in the message, "control that has focus",
is misleading. IMO, they should have said "the active
control" and there is almost always an active control on
every form.

Think about it, what is the form supposed to display when
you hide the active tab page? What should Access do when
the active control becomes invisible? If you make a
different tab page and a different control in the subform
active, the problem should not occur.
 
M

Marshall Barton

JimiiZ said:
I actually have multiple tabs and the other one will hide no problem because
it does not have focus. This is tied to a clear form button and everything
is being reset. The subforms become visible depending on user choices....I
guess you could say its a sequence of events and Im having trouble stopping
it like once in a while I come across a transaction error (not in this
database though).


Have you tried setting the focus to some other control on
the subform control and then making whatever tab page will
remain visible the selected page? The subform code for that
is like:
Me.somecontrol.SetFocus
Me.tabcontrol = <0 based page number>
Me.tabcontrol.Page(x).Visible = False

If you are doing that stuff in the main form:

With Me.subformcontrol.Form
.somecontrol.SetFocus
.tabcontrol = <0 based page number>
.tabcontrol.Page(x).Visible = False
End With
 
J

JimiiZ via AccessMonster.com

Yes, I have tried all kinds of things. I believe the problem is that I have
a form, with a subform, with two subforms in that. It is those two sub-
subforms where I have an issue. If the user hits a button in the sub-subform
it seems to not release the focus no matter what I try, although there is a
field in the main form highlighted as it has focus, the button is highlighted
also.

The work around I am using until I find somthing better is that I hide it
when the sub-subform gets called on so the user see's it for a second and
then it gets hidden until its needed. I cant seem to trap any other time
when it allows me to hide it....

Again, probably bad coding and design but it actually works smoother for the
intended use with the embedded sub-subforms instead of more tabs on the main
form....And, to be honest so someone can chime in and tell me im doing all
this wrong but the subform is a continuous form so there really should be no
subforms, but it works great other than the one little glitch ;-)
 
M

Marshall Barton

JimiiZ said:
Yes, I have tried all kinds of things. I believe the problem is that I have
a form, with a subform, with two subforms in that. It is those two sub-
subforms where I have an issue. If the user hits a button in the sub-subform
it seems to not release the focus no matter what I try, although there is a
field in the main form highlighted as it has focus, the button is highlighted
also.

The work around I am using until I find somthing better is that I hide it
when the sub-subform gets called on so the user see's it for a second and
then it gets hidden until its needed. I cant seem to trap any other time
when it allows me to hide it....

Again, probably bad coding and design but it actually works smoother for the
intended use with the embedded sub-subforms instead of more tabs on the main
form....And, to be honest so someone can chime in and tell me im doing all
this wrong but the subform is a continuous form so there really should be no
subforms, but it works great other than the one little glitch ;-)

Well, I can't pretend to have a clear picture of what your
forms are doing, but it sound llke you have found a
marginally acceptable workaround so I guess you can go on to
other things.
 
J

JimiiZ via AccessMonster.com

Thank you for you input, it is appreciated. Having no programmers in house
sometimes its just helpful to talk about what your doing and it promotes new
ideas.

The database is actually just a complex order form, the subform being a
continuous form. At line item entry there are options to set, discounts and
such. If you pick a certain product number, the sub-subforms appear for
options that go along with that item so in trying to hide them I am just
trying to reset the form for the user to start again.

Marshall said:
Yes, I have tried all kinds of things. I believe the problem is that I have
a form, with a subform, with two subforms in that. It is those two sub-
[quoted text clipped - 13 lines]
this wrong but the subform is a continuous form so there really should be no
subforms, but it works great other than the one little glitch ;-)

Well, I can't pretend to have a clear picture of what your
forms are doing, but it sound llke you have found a
marginally acceptable workaround so I guess you can go on to
other things.
 

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