473,383 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to identify the control that has focus?

Hi folks,

Screen.PreviousControl.SetFocus works fine to select the control that
had focus prior to the one that NOW has focus. Unfortunately, I've
not discovered a VBA code way to get the name of the control, that
currently has focus. It would be nice if the Screen object had a
property called "CurrentControl" that could be stored in a variable,
as in: "X = Screen.CurrentControl.Name"

Am I overlooking something?

Any advice will be appreciated.
Nov 12 '05 #1
7 85556
On Thu, 23 Oct 2003 13:12:31 -0500, William Case
<re**********@nospam.zap> wrote in comp.databases.ms-access:

Screen.PreviousControl.SetFocus works fine to select the control that
had focus prior to the one that NOW has focus. Unfortunately, I've
not discovered a VBA code way to get the name of the control, that
currently has focus. It would be nice if the Screen object had a
property called "CurrentControl" that could be stored in a variable,
as in: "X = Screen.CurrentControl.Name"

Am I overlooking something?


Yes. Screen.ActiveControl
Peter Miller
__________________________________________________ __________
PK Solutions -- Data Recovery for Microsoft Access/Jet/SQL
Free quotes, Guaranteed lowest prices and best results
www.pksolutions.com 1.866.FILE.FIX 1.760.476.9051
Nov 12 '05 #2
Screen.Activecontrol.Name

Regards

Peter Russell
William Case previously wrote:
Hi folks,

Screen.PreviousControl.SetFocus works fine to select the control that
had focus prior to the one that NOW has focus. Unfortunately, I've
not discovered a VBA code way to get the name of the control, that
currently has focus. It would be nice if the Screen object had a
property called "CurrentControl" that could be stored in a variable,
as in: "X = Screen.CurrentControl.Name"

Am I overlooking something?

Any advice will be appreciated.


Nov 12 '05 #3
On Thu, 23 Oct 2003 18:20:40 GMT, Peter Miller
<pm*****@pksolutions.com> wrote:
On Thu, 23 Oct 2003 13:12:31 -0500, William Case
<re**********@nospam.zap> wrote in comp.databases.ms-access:

Screen.PreviousControl.SetFocus works fine to select the control that
had focus prior to the one that NOW has focus. Unfortunately, I've
not discovered a VBA code way to get the name of the control, that
currently has focus. It would be nice if the Screen object had a
property called "CurrentControl" that could be stored in a variable,
as in: "X = Screen.CurrentControl.Name"

Am I overlooking something?


Yes. Screen.ActiveControl


Thanks Peter. I just tried to do this. Screen.ActiveControl has no
Name property!
Nov 12 '05 #4
On Thu, 23 Oct 2003 19:26 +0100 (BST), ru***@127.0.0.1 (Peter Russell)
wrote:
Screen.Activecontrol.Name
Thanks. Unfortunately, >Screen.Activecontrol has no Name property.
It should, but it does not. Now what?
Regards

Peter Russell
William Case previously wrote:
Hi folks,

Screen.PreviousControl.SetFocus works fine to select the control that
had focus prior to the one that NOW has focus. Unfortunately, I've
not discovered a VBA code way to get the name of the control, that
currently has focus. It would be nice if the Screen object had a
property called "CurrentControl" that could be stored in a variable,
as in: "X = Screen.CurrentControl.Name"

Am I overlooking something?

Any advice will be appreciated.


Nov 12 '05 #5

On Thu, 23 Oct 2003 16:20:43 -0500, William Case
<re**********@nospam.zap> wrote in comp.databases.ms-access:
Thanks Peter. I just tried to do this. Screen.ActiveControl has no
Name property!


But of course it does.

Did you actually try this?

Remember that in order to use the name property, there must be an
active control. If you are testing and you don't actually have an
active control, then of course, you can't get its name.

If you're wondering why intellisense doesn't offer a name property
when the active control *does* exist, remember that activecontrol is a
placeholder or generic object pointer. It will, as a result, allow
for the use of methods and properties that are legal for the active
control, even if not common to all controls and therefore not listed
in intellisense popups.
Peter Miller
__________________________________________________ __________
PK Solutions -- Data Recovery for Microsoft Access/Jet/SQL
Free quotes, Guaranteed lowest prices and best results
www.pksolutions.com 1.866.FILE.FIX 1.760.476.9051
Nov 12 '05 #6
RE/

Thanks. Unfortunately, >Screen.Activecontrol has no Name property.
It should, but it does not. Now what?


It does - Microsoft is just messing with your mind in the IntelliSense dropdown.

Just try it:
-------------------------
Private Sub cmdTestActiveControl_Click()
MsgBox Screen.ActiveControl.Name, 0, "Gotcha!"
End Sub
-------------------------

One caveat: If you're running in line-by-line debugging mode, it will fail
because the code window is active.
--
PeteCresswell
Nov 12 '05 #7
x@y.z ((Pete Cresswell)) wrote in
<re********************************@4ax.com>:
RE/

Thanks. Unfortunately, >Screen.Activecontrol has no Name
property. It should, but it does not. Now what?


It does - Microsoft is just messing with your mind in the
IntelliSense dropdown.

Just try it:
-------------------------
Private Sub cmdTestActiveControl_Click()
MsgBox Screen.ActiveControl.Name, 0, "Gotcha!"
End Sub
-------------------------

One caveat: If you're running in line-by-line debugging mode, it
will fail because the code window is active.


Not in Access 2000.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Julie | last post by:
I am trying to set some checks on my tab pages. I have many sets of tab control pages with many controls on each page. I have got the code on the button to check each control to make sure it has an...
2
by: Elliot M. Rodriguez | last post by:
Is it possible to change a control's focus at runtime? I'm sure you can.... I have a form with 2 textbox controls that cause postbacks. They are located in the middle of my form. When a...
3
by: Paul | last post by:
Just wondering if there is a way to give a control focus when the page loads, for example so the user could start typing in a text box before clicking on it? Thanks, -- Paul G Software engineer.
3
by: veera | last post by:
Is it possible to give control focus using Asp.net code??
0
by: LCAdeveloper | last post by:
Another newbie question I'm afraid. When I use the .Focus() or .Select() methods to set the initial control that has focus on a form, try as I might I cannot get the control to visually indicate...
1
by: robin9876 | last post by:
In Asp.Net v1.1 web form I have a number of controls which have the autopostback enabled. Is it possible after the autopostback has run that the control that caused the autopostback to get the...
9
by: Zytan | last post by:
http://msdn2.microsoft.com/en-us/system.windows.forms.control.focus(VS.80).aspx this page says: "Focus is a low-level method intended primarily for custom control authors. Instead, application...
1
by: Ryan | last post by:
Hello, I am starting the use the new ajax.net and I am seeing a bizarre behavior when controlling focus from the codebehind. I have tried: <control>.focus page.setfocus(<control>)...
3
by: zacks | last post by:
I am working on an application that has a UI that supports multiuple functions by means of a group of "plug ins". Each plugin is a class library. Each plugin contains a User Control that defines...
1
by: Pramod K S | last post by:
Hello, How to identify control characters in a url and remove those using php? Thanks.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.