473,396 Members | 2,003 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,396 software developers and data experts.

Getting Active Control During Current Event

I have some code in my form's On Current event which changes focus to a
particular control. I want the control to remain where it was when the user
moved to the new record. But using Screen.ActiveControl or Me.ActiveControl
in the OnCurrent event results in the error "the expression you entered
requires the control to be in the active window" (2474).

How can I determine the control that had the focus before moving to the new
record, so that I can change it back there afterwards? Thanks!
Nov 20 '07 #1
7 4508
I think what you actually want is Screen.PreviousControl

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Neil" <no****@nospam.netwrote in message
news:7u*******************@newssvr14.news.prodigy. net...
>I have some code in my form's On Current event which changes focus to a
particular control. I want the control to remain where it was when the user
moved to the new record. But using Screen.ActiveControl or Me.ActiveControl
in the OnCurrent event results in the error "the expression you entered
requires the control to be in the active window" (2474).

How can I determine the control that had the focus before moving to the
new record, so that I can change it back there afterwards? Thanks!

Nov 20 '07 #2
Hmm, interesting thought. So if the focus is in CtrlA, and then the user
moves to another record, you're saying that it leaves CtrlA and goes
somewhere else while it's in the Current event, and then returns to CtrlA
when it gets to the new record?

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.comwrote in message
news:eF**************@TK2MSFTNGP05.phx.gbl...
>I think what you actually want is Screen.PreviousControl

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Neil" <no****@nospam.netwrote in message
news:7u*******************@newssvr14.news.prodigy. net...
>>I have some code in my form's On Current event which changes focus to a
particular control. I want the control to remain where it was when the
user moved to the new record. But using Screen.ActiveControl or
Me.ActiveControl in the OnCurrent event results in the error "the
expression you entered requires the control to be in the active window"
(2474).

How can I determine the control that had the focus before moving to the
new record, so that I can change it back there afterwards? Thanks!


Nov 21 '07 #3
Neil wrote:
Hmm, interesting thought. So if the focus is in CtrlA, and then the
user moves to another record, you're saying that it leaves CtrlA and
goes somewhere else while it's in the Current event, and then returns
to CtrlA when it gets to the new record?
Are you wanting move the focus smewhere else and then move it back to the
control that previously had focus? For what purpose?

If you just want the current control to keep focus as you navigate that is the
normal behavior for an Access form. If focus is moving it is because you have a
macro or code that is causing it to do so.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Nov 21 '07 #4
One thing to be aware of is that a popup form can't be referenced
through screen. (activeform or activecontrol) this will produce an
error.
The other thing is that you can't be in the VBA window when you run
this code (because the control doesn't have focus)

Use the Debug.Print to determine if it had the right focus when it ran
your code.

The Screen.ActiveControl.Name should provide you with the name of the
control.

Regards
Anthony Moore
Nov 21 '07 #5
Yes, it's not a pop-up form, and I am using debug.print
screen.activecontrol.name. That's the line that's generating the error.

Well, maybe it's something in my code. I'll look a little deeper.
"Anthos" <an*****@itexcellence.com.auwrote in message
news:20**********************************@y5g2000h sf.googlegroups.com...
One thing to be aware of is that a popup form can't be referenced
through screen. (activeform or activecontrol) this will produce an
error.
The other thing is that you can't be in the VBA window when you run
this code (because the control doesn't have focus)

Use the Debug.Print to determine if it had the right focus when it ran
your code.

The Screen.ActiveControl.Name should provide you with the name of the
control.

Regards
Anthony Moore

Nov 21 '07 #6
Is it a subform?
Nov 22 '07 #7
No, it's just a regular form, with no subforms in it, even, and there's no
pop-up form open or anything. Just a plain ole form.

"Anthos" <an*****@itexcellence.com.auwrote in message
news:f1**********************************@s6g2000p rc.googlegroups.com...
Is it a subform?

Nov 22 '07 #8

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

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
2
by: Gerry Abbott | last post by:
Hi all. Im using abbreviated field names on a form to optimise space, but would like to display for example, the status bar text of the control, onto the form header, when the control has the...
4
by: TS | last post by:
When i try to access the page class or parent properties inside a server control that is nested in another server control, they are null. I don't even call CreateChildControls for the parent...
11
by: Hoku | last post by:
I am using dual monitors on a dual head ATI AGP4x video card. I installed the Nov 11 2005 release of ATI's catalyst control center with Hydravision to manage the dual monitor setup. I recently...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
3
by: Atul | last post by:
Hi, I am running .NET Framework 2.0 on windows XP SP2. I am stuck in a situation where I need to find out a list of all active sessions running in IIS for a web application. I know that .NET...
3
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
I have VS 2005 (C#) There is a control numericUpDown so you can spin numeric values. What I need to do is to spin date (+- one day). How to do that? Moreover, I want a user to type the date as...
2
by: Simit Kulkarni | last post by:
Hi All, I am stucked with a problem , regarding Repeater Controls Header Template. I want to show a Image Button in the Header Template of a Repeater Control and on the Click of...
0
by: ananth | last post by:
Hi All, I have a active-x control that checks the registry for whether a file has been installed or not if it is not installed then it will get a content using a property file which has the...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.