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!

Run-time error '2165' - You can't hide a control that has focus...

Status
Not open for further replies.

SnayJ

Programmer
Feb 27, 2008
65
0
0
US
Here is what I want to do... I want to have minimize and maximize buttons on my form, but I do not want a control box. Also, I do not mean Minimize/Maximize like the controls in the Control Box. I mean in minimized form - the form is very small (limiting view to 1 textbox and the min/max buttons; and maximize would open the form to display many other controls.

So I put two Labels on my form, 1 with a Down Arrow Image (Maximize) [MAXIMIZEcmd] and 1 with an Up Arrow Image (Minimize) [MINIMIZEcmd]. When the user clicks one label, I change the form size using docmd.movesize, and then I want to hide the label just used and show the other label... but obviously am getting the 2165 error.

How do I get around this? Oh I had also just thought of changing the image when clicked... but the property just says "image..." so I don't know how to identify the UpArrow and/or DownArrow image.
 
So it is not really Minimize / Maximize, it is just 'reside' down and 'reside' up.
The way I see it you can use just one label:
When form is big, show arrow down to size it down,
When form is small, show arrow up to size it up.

"changing the image when clicked" look up LoadPicture Function

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Andy - Appreciate the reply. I had mentioned nearly the same thing (last sentence of my post)... but I can't determine what the image names are for the command buttons. When you choose a image thru the chooser, you don't get to see it's name. It appears in the property as "(image)". I could just put in an image instead of a command button, which is what it sounds like you were saying. But again, it doesn't give a path to the image... it's embedded. So how do I change the image in code? If I were to do it, the only way I can think to do it would be the same... 2 images... hide 1 and show the other... which will result in the same error. I guess I could go with using a text option on the command button and finding a Wingdings like font of an up/down arrow and change it that way. I was trying to do command button images though because I liked the images. Thoughts?
 
I just tried to do the Text change for the Command Button and it doesn't work either... ASCII for Down Arrow is 31 and Up is 30... and neither are printable. If I do a debug.print RESIZEcmd.caption... I get "?
 
Try something like this:

Code:
Private Sub CommandButton1_Click()

With CommandButton1
    If .Caption = "UP" Then
        .Caption = "DN"
        Set .Picture = LoadPicture("E:\Andrzej\DN.jpg")
    Else
        .Caption = "UP"
        Set .Picture = LoadPicture("E:\Andrzej\UP.jpg")
    End If
End With

End Sub

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Sorry... probably didn't give enough information. Would work great if it was just my program. But, I can't direct link an image like that if I distribute the program to different users... or can I?
 
You can always do this:

Code:
With CommandButton1
    If .Caption = "Make it Large" Then
        .Caption = "Make it Small"
    Else
        .Caption = "Make it Large"
    End If
End With

"ASCII for Down Arrow is 31 and Up is 30" - could you share your code of how you were going to accomplish this?

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Yeah...looks like I'm going to have to do it with text. I can't share because I couldn't figure out a way to use the Ascii (30/31) in code. Thanks for trying though... I think I'm going to leave it as 1 button that minimizes the form and a different option to maximize it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top