473,320 Members | 1,713 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,320 software developers and data experts.

which control has the focus

Hi all,
Ive got a form with several controls which contain date fields. I'm usng the
activex calender control as a separate floating form, I would like to be
able to click onto any of the date fields and use the calender to drop a
date into it.

So far, I've managed to drop the date selected from the calener, into a
specified control, and requery the control to display the newly added date.
Works fine using the rs object.

However what i need to know is the name of the currently selected control
and field, then I can tell the calender control exactly what to do. I've
tried the screen.previouscontrol, and this works fine when I open the
calender, but I can't get it to work when I simply switch focus to a new
date control, and try to use the calender again.

Am i on the right track for a solution.

Thanks

Gerry Abbott


Nov 13 '05 #1
7 4437
MA

"Gerry Abbott" <pl****@ask.ie> ha scritto nel messaggio
news:tk*******************@news.indigo.ie...
Hi all,
Ive got a form with several controls which contain date fields. I'm usng the activex calender control as a separate floating form, I would like to be
able to click onto any of the date fields and use the calender to drop a
date into it.

So far, I've managed to drop the date selected from the calener, into a
specified control, and requery the control to display the newly added date. Works fine using the rs object.

However what i need to know is the name of the currently selected control
and field, then I can tell the calender control exactly what to do. I've
tried the screen.previouscontrol, and this works fine when I open the
calender, but I can't get it to work when I simply switch focus to a new
date control, and try to use the calender again.

Am i on the right track for a solution.

Thanks

Gerry Abbott

Save the name of screen.activecontrol in a varible of the form
Declare it on the top of the module
Dim ControlToRemember as string
when you need you save it

ControlToRemember = screen.activecontrol.name
After used remember to clean it
MAssimiliano
Nov 13 '05 #2
Sounds good.
But probably have to declare it as public, in order to use it in the second
(calender) form.
Thanks.

"MA" <ma****@massimilianoamendola.it> wrote in message
news:J6*******************@news.edisontel.com...

"Gerry Abbott" <pl****@ask.ie> ha scritto nel messaggio
news:tk*******************@news.indigo.ie...
Hi all,
Ive got a form with several controls which contain date fields. I'm usng

the
activex calender control as a separate floating form, I would like to be
able to click onto any of the date fields and use the calender to drop a
date into it.

So far, I've managed to drop the date selected from the calener, into a
specified control, and requery the control to display the newly added

date.
Works fine using the rs object.

However what i need to know is the name of the currently selected control
and field, then I can tell the calender control exactly what to do. I've
tried the screen.previouscontrol, and this works fine when I open the
calender, but I can't get it to work when I simply switch focus to a new
date control, and try to use the calender again.

Am i on the right track for a solution.

Thanks

Gerry Abbott

Save the name of screen.activecontrol in a varible of the form
Declare it on the top of the module
Dim ControlToRemember as string
when you need you save it

ControlToRemember = screen.activecontrol.name
After used remember to clean it
MAssimiliano

Nov 13 '05 #3
No, that did not work, so had to declare it in a standard module as a public
variable. That way it can be seen from all class modules.
"Gerry Abbott" <pl****@ask.ie> wrote in message
news:pu*******************@news.indigo.ie...
Sounds good.
But probably have to declare it as public, in order to use it in the
second (calender) form.
Thanks.

"MA" <ma****@massimilianoamendola.it> wrote in message
news:J6*******************@news.edisontel.com...

"Gerry Abbott" <pl****@ask.ie> ha scritto nel messaggio
news:tk*******************@news.indigo.ie...
Hi all,
Ive got a form with several controls which contain date fields. I'm usng

the
activex calender control as a separate floating form, I would like to be
able to click onto any of the date fields and use the calender to drop a
date into it.

So far, I've managed to drop the date selected from the calener, into a
specified control, and requery the control to display the newly added

date.
Works fine using the rs object.

However what i need to know is the name of the currently selected
control
and field, then I can tell the calender control exactly what to do. I've
tried the screen.previouscontrol, and this works fine when I open the
calender, but I can't get it to work when I simply switch focus to a new
date control, and try to use the calender again.

Am i on the right track for a solution.

Thanks

Gerry Abbott

Save the name of screen.activecontrol in a varible of the form
Declare it on the top of the module
Dim ControlToRemember as string
when you need you save it

ControlToRemember = screen.activecontrol.name
After used remember to clean it
MAssimiliano


Nov 13 '05 #4
I'm still struggling.
My problem is with the ActiveControl object.
Ive tried to return the name from the Activate, Current, and Got Focus
events but without success. I have managed to do it with the click on a
button control, but that's too late for what I require. I need to return
this value as soon a the user clicks anywhere on the subform.
What event should I use to return this, so that when i click on the control
it returns the current control name in this way ?

Thanks in advance.

Gerry Abbot

"Gerry Abbott" <pl****@ask.ie> wrote in message
news:oH*******************@news.indigo.ie...
No, that did not work, so had to declare it in a standard module as a
public variable. That way it can be seen from all class modules.
"Gerry Abbott" <pl****@ask.ie> wrote in message
news:pu*******************@news.indigo.ie...
Sounds good.
But probably have to declare it as public, in order to use it in the
second (calender) form.
Thanks.

"MA" <ma****@massimilianoamendola.it> wrote in message
news:J6*******************@news.edisontel.com...

"Gerry Abbott" <pl****@ask.ie> ha scritto nel messaggio
news:tk*******************@news.indigo.ie...
Hi all,
Ive got a form with several controls which contain date fields. I'm
usng
the
activex calender control as a separate floating form, I would like to
be
able to click onto any of the date fields and use the calender to drop
a
date into it.

So far, I've managed to drop the date selected from the calener, into a
specified control, and requery the control to display the newly added
date.
Works fine using the rs object.

However what i need to know is the name of the currently selected
control
and field, then I can tell the calender control exactly what to do.
I've
tried the screen.previouscontrol, and this works fine when I open the
calender, but I can't get it to work when I simply switch focus to a
new
date control, and try to use the calender again.

Am i on the right track for a solution.

Thanks

Gerry Abbott

Save the name of screen.activecontrol in a varible of the form
Declare it on the top of the module
Dim ControlToRemember as string
when you need you save it

ControlToRemember = screen.activecontrol.name
After used remember to clean it
MAssimiliano



Nov 13 '05 #5
try PreviousControl insead of ActiveControl

HTH
Paul

"Gerry Abbott" <pl****@ask.ie> wrote in message
news:Hm*******************@news.indigo.ie...
I'm still struggling.
My problem is with the ActiveControl object.
Ive tried to return the name from the Activate, Current, and Got Focus
events but without success. I have managed to do it with the click on a
button control, but that's too late for what I require. I need to return
this value as soon a the user clicks anywhere on the subform.
What event should I use to return this, so that when i click on the
control it returns the current control name in this way ?

Thanks in advance.

Gerry Abbot

"Gerry Abbott" <pl****@ask.ie> wrote in message
news:oH*******************@news.indigo.ie...
No, that did not work, so had to declare it in a standard module as a
public variable. That way it can be seen from all class modules.
"Gerry Abbott" <pl****@ask.ie> wrote in message
news:pu*******************@news.indigo.ie...
Sounds good.
But probably have to declare it as public, in order to use it in the
second (calender) form.
Thanks.

"MA" <ma****@massimilianoamendola.it> wrote in message
news:J6*******************@news.edisontel.com...

"Gerry Abbott" <pl****@ask.ie> ha scritto nel messaggio
news:tk*******************@news.indigo.ie...
> Hi all,
> Ive got a form with several controls which contain date fields. I'm
> usng
the
> activex calender control as a separate floating form, I would like to
> be
> able to click onto any of the date fields and use the calender to drop
> a
> date into it.
>
> So far, I've managed to drop the date selected from the calener, into
> a
> specified control, and requery the control to display the newly added
date.
> Works fine using the rs object.
>
> However what i need to know is the name of the currently selected
> control
> and field, then I can tell the calender control exactly what to do.
> I've
> tried the screen.previouscontrol, and this works fine when I open the
> calender, but I can't get it to work when I simply switch focus to a
> new
> date control, and try to use the calender again.
>
> Am i on the right track for a solution.
>
> Thanks
>
> Gerry Abbott
>
Save the name of screen.activecontrol in a varible of the form
Declare it on the top of the module
Dim ControlToRemember as string
when you need you save it

ControlToRemember = screen.activecontrol.name
After used remember to clean it
MAssimiliano



Nov 13 '05 #6
Could not get either the active control or the pastcontrol objects to work
satisfactorily.

Ok Here's a solution, but it does not involve activecontrol.

I placed a reference unbound, invisible control on the main form. On the
click event of the subforms and their controls, I used the parent property
to write into this invisible control. What is written in, depending on Which
subform is doing the writing.

Then on pop up, just referenced the value in this control, and took action
appropriate to that value.

Gerry

"Paul" <pz****@rogers.com> wrote in message
news:pI********************@rogers.com...
try PreviousControl insead of ActiveControl

HTH
Paul

"Gerry Abbott" <pl****@ask.ie> wrote in message
news:Hm*******************@news.indigo.ie...
I'm still struggling.
My problem is with the ActiveControl object.
Ive tried to return the name from the Activate, Current, and Got Focus
events but without success. I have managed to do it with the click on a
button control, but that's too late for what I require. I need to return
this value as soon a the user clicks anywhere on the subform.
What event should I use to return this, so that when i click on the
control it returns the current control name in this way ?

Thanks in advance.

Gerry Abbot

"Gerry Abbott" <pl****@ask.ie> wrote in message
news:oH*******************@news.indigo.ie...
No, that did not work, so had to declare it in a standard module as a
public variable. That way it can be seen from all class modules.
"Gerry Abbott" <pl****@ask.ie> wrote in message
news:pu*******************@news.indigo.ie...
Sounds good.
But probably have to declare it as public, in order to use it in the
second (calender) form.
Thanks.

"MA" <ma****@massimilianoamendola.it> wrote in message
news:J6*******************@news.edisontel.com...
>
> "Gerry Abbott" <pl****@ask.ie> ha scritto nel messaggio
> news:tk*******************@news.indigo.ie...
>> Hi all,
>> Ive got a form with several controls which contain date fields. I'm
>> usng
> the
>> activex calender control as a separate floating form, I would like to
>> be
>> able to click onto any of the date fields and use the calender to
>> drop a
>> date into it.
>>
>> So far, I've managed to drop the date selected from the calener, into
>> a
>> specified control, and requery the control to display the newly added
> date.
>> Works fine using the rs object.
>>
>> However what i need to know is the name of the currently selected
>> control
>> and field, then I can tell the calender control exactly what to do.
>> I've
>> tried the screen.previouscontrol, and this works fine when I open the
>> calender, but I can't get it to work when I simply switch focus to a
>> new
>> date control, and try to use the calender again.
>>
>> Am i on the right track for a solution.
>>
>> Thanks
>>
>> Gerry Abbott
>>
> Save the name of screen.activecontrol in a varible of the form
> Declare it on the top of the module
>
>
> Dim ControlToRemember as string
>
>
> when you need you save it
>
> ControlToRemember = screen.activecontrol.name
> After used remember to clean it
> MAssimiliano
>
>



Nov 13 '05 #7
rkc

"Gerry Abbott" <pl****@ask.ie> wrote in message
news:tk*******************@news.indigo.ie...
Hi all,
Ive got a form with several controls which contain date fields. I'm usng the activex calender control as a separate floating form, I would like to be
able to click onto any of the date fields and use the calender to drop a
date into it.


<snip snip snip>

Pass the control name to the calendar form as the openargs parameter of
a DoCmd.Openform call and set the passed in control's value in the calendar
control's click event. I'm too lazy to try it at the moment but I don't
think
it matters if the calendar form is already open.

I usually do this with a class using WithEvents that opens a calendar form
when a textbox is either double clicked or ctrl-C is pressed. The big
difference is the calendar form isn't left floating around, it's opened when
needed. The calendar isn't opened OnEnter in case the user just wants
to go ahead and type in the date.



Nov 13 '05 #8

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

Similar topics

2
by: Liam McNamara | last post by:
I am having the same problem as the one I found in google below: ...
2
by: Marco Liedekerken | last post by:
Hi, Is it possible to retrieve the control that had the focus when the page was posted back? Because the focus is lost when a postback occurs I want to manually set the focus to the control...
2
by: bill | last post by:
I have the following user control in my project simply for setting focus to a control: Public Class SetFocus Inherits System.Web.UI.UserControl
3
by: julien | last post by:
Hi, after the OnCLick event, when I am in the function that deal with the event, I want to retrieve the control that had the focus on the page? How can I do this please? Thanks in advance. JULIEN
2
by: Tom | last post by:
I am developing a VB.NET user control that is composed of a component control (along with some classes, etc). This is probably a stupid question, and should be easy, but I must be having a brain...
0
by: Nick | last post by:
I have a situation wherein i have a text box, that has abc() being executed whenever the lost focus event is triggered. However, there is an exceptional case where, if a button click causes the...
1
by: clickon | last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains a text box, TextBox1 and TextBox2 respectively. If i put the following code in the respective activate event handlers for...
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...
3
by: Nathan Laff | last post by:
I have a custom Control that is a label, however I inherit from Control... 1) I override onClick and do a DrawFocusRectangle, that works great. How do I clear the focus rectangle once something...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.