INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

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

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

(OP)
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.

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

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.

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

(OP)
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?

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

(OP)
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 "?"

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

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.

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

(OP)
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?

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

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.

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

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close