Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
252 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

722 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