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!

Remove Focus

Status
Not open for further replies.

puforee

Technical User
Oct 6, 2006
741
US
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,
 
How can I, in code
Well, which code ???

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
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.
 
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.
 
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,
 
We need to see the code that you are using to help you troubleshoot.
 
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 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
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,
 
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 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
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 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
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,
 
puforee said:
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top