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
248 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 500 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

752 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