Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I remove the focus off a control through a macro so that I can hide it?

Posted on 2008-10-05
2
Medium Priority
?
253 Views
Last Modified: 2013-11-28
I have a macro that hides a number of controls after clicking a control called cmdLogout. However, I want cmdLogout to also hide as the macro executes. But this brings up an error because it cannot hide a control that has the focus. How do i remove the focus from the control so that it can be hidden?
0
Comment
Question by:Anneline
2 Comments
 
LVL 34

Accepted Solution

by:
Mike Eghtebas earned 2000 total points
ID: 22647093
On your form add a text box (txtDummy). It remains unbound (nothing in its control soutce), width = 0.

In Gotfocus event of txtDummy have:

txtName.visible = false
.
.
.
cmdLogout.visible = false
etc.

And in Click event of cmdLogout have:

Sub cmdLogout_Click()
.
.your existing code
.

Me!txtDummy.SetFocus
End Sub

Mike
0
 

Author Closing Comment

by:Anneline
ID: 31503296
Thanks!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question