Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visibility Turned Off 3

Status
Not open for further replies.

tubbsy123

Programmer
Dec 2, 2004
19
0
0
AU
Hi,

I have a very basic query which turns the visibility of items in a form on or off depending which button has been pressed.

The query fires on click.

A condensed version of some of the code reads:

Private Sub btnElecBack_Click()

picGas.Visible = True
btnElecTotal.Visible = True
btnElecBack.Visible = False

End Sub


The problem occurs when I try to hide the button being used. I get an error saying that the button cannot be hidden.

Any ideas??

 
You can't hidden a control when it has the focus.
You may try this:
Private Sub btnElecBack_Click()
...
btnElecTotal.Setfocus
btnElecBack.Visible = False
End Sub


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya tubbsy123 . . .

You can't hide a control while it has the focus, just move the focus elsewhere first (and not a hidden control).
Code:
[blue]   Me!TextboxName.SetFocus[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Slightly off topic - having come from a VB6 background, it's been a long-standing gripe of mine that Access has these stupid "you must have focus to do this" or "can't do this while control has the focus" rules.

One of my strategies for dealing with this is making a tiny little "dummy" button that I can set focus to (because sometimes it just looks odd when some other control gets the focus). I usually hide the dummy button under another control. It just feels so kludgy, I feel dirty every time I do it. One of the many little reasons I like VB6 over Access.


 
G'day JoeAtWork

I use a textbox for the same purpose... txtPlaceHolder. Width=0, Top=0, Left=0, Enabled=Y, Locked=Y.

I have one on virtually every form, and its first in the tab order. Gets used a lot.

Max Hugen
Australia
 
I tried the dummy text box and it worked perfectly.

Frog40
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top