Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I am very happy with the whole site and would like to extend my compliments to all of you who work to make it one of the most useful sites (If not THE Most Useful) ...and the easiest to navigate..."

Geography

Where in the world do Tek-Tips members come from?
puforee (TechnicalUser)
17 Jul 12 12:38
I have a employee form. On the form I can select a status..New, Revise, Complete, Remove.

This form has several sub forms. Each sub-form is for different computing systes or servers. I track each employee’s access with this tool.

When "Revise" status is selected, each sub form shows a "Remove" check box. This check box only shows when the Status is set to Revise. If I check the checkbox and then try to change the status to Complete I get an error. When selecting Complete, code runs to make the "Remove" check boxes Not visible. The error I get is that I cannot make an object that "has focus" Not visible.

Makes sense. I have tried removing the focus from the check box to other objects that are not effected by the Not visible code. Does not work...the check box still has focus.

Finally...the Question. How can I, in code, remove the focus from the check box?

Thanks,
puforee (TechnicalUser)
17 Jul 12 16:22
Thans PHV. So, when I click one of the status buttons, in this case the status is Revise and I click complete. Even code runs to set up the Forms for the Complete view. Certian objects are locked etc.

One of the items in the code VBA, is to turn off the visability of the "Remove" check boxes on all the sub-forms. If I have checked or unchecked any one of this boxes and then select the status of "Complete" the code runs but errors stating it cannot make the object Not Visable as long as it still has focus. I want to add a VBA code to remove the check box focus OR change the focus to an uneffected object...then the Not visable part of the VBA can run without error.

Thanks...hope this helps.
jkl0 (TechnicalUser)
19 Jul 12 9:01
A quick and easy method would be to open a user form to simulate a messagebox with some generic message and an OK button. This will take the focus away from your form.
Then in the OnOpen event of your new form, you can loop through the controls, on the original form, that you want to turn off, "Forms!frmName!txtControlName.Visible = False", to turn off your controls.
The OK button on your fake messagebox just closes that form.
puforee (TechnicalUser)
19 Jul 12 12:13
jkl0 Thanks for the reply. I don't have an issue with the form having focus. The issue is one of the "Remove" Checkbox objects on a subform has the focus. I even tried selecting anothe object, then tried saving, and I still get the error. "You cannot Make the Opject NOT Visable when it has focus." So it is the checkbox object that I cannot remove the focus from.

Any other ideas?

Thanks,
jkl0 (TechnicalUser)
19 Jul 12 14:15
We need to see the code that you are using to help you troubleshoot.
TheAceMan1 (Programmer)
23 Jul 12 5:29
How are ya puforee . . .

This doesn't make many sense as you move the focus from the checkbox to the status control when you change from Revise to Complete. I'm saying the focus is already moved!

Perhaps you have some code in the focus events of the remove checkboxes?

See Ya! . . . . . .

Be sure to see FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions? Worthy Reading! thumbsup2
Also FAQ181-2886: How can I maximize my chances of getting an answer? Worthy Reading! thumbsup2

puforee (TechnicalUser)
24 Jul 12 10:10
Everyone...I think I have an idea about what is happening. I have a Main Form with several sub forms as I have said. When I click on the Remove check box on the SUB-FORM....and then Click the COMPLETE status on the MAIN form...code runs to make the Remove check box not visable. But, I now believe the SUB FORM check box continues to have focus.....since I have changed to the main form.

Does this make sense?

So, again, is there code I can use to Remove Focus from an object "Lost Focus"? I could run this code before I try to set the object to not visable.

Thanks,
TheAceMan1 (Programmer)
24 Jul 12 13:07
puforee . . .

... and what event are you using in the status control to run the code?

BTW ... what type of control is status?

See Ya! . . . . . .

Be sure to see FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions? Worthy Reading! [thumbsup2]
Also FAQ181-2886: How can I maximize my chances of getting an answer? Worthy Reading! [thumbsup2]

puforee (TechnicalUser)
24 Jul 12 15:23
After update
TheAceMan1 (Programmer)
25 Jul 12 1:39
puforee . . .

Your latest post is proof that the Status control has the focus when code runs ... not the Remove checkbox.

See Ya! . . . . . .

Be sure to see FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions? Worthy Reading! thumbsup2
Also FAQ181-2886: How can I maximize my chances of getting an answer? Worthy Reading! thumbsup2

puforee (TechnicalUser)
26 Jul 12 17:01
That is not what I was saying. I wanted to send you a document but I don't know how to attache it...word document.

What I am saying is: Both the main form Status and the SubForm Revise have focus. My document proves this.

Again, my only question is: Is there code I can write to remove the focus from a control.

Thanks guys,
jges (TechnicalUser)
27 Jul 12 15:29

Quote (puforee)

Is there code I can write to remove the focus from a control.

Give the focus to a different (more appropriate) control or to the form itself. Something like:

CODE

text1.SetFocus 

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!

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