473,467 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How does this work?

Following code belongs to the first field in form B. When I open form B from
form A, ctl.Name returns the name of Form's A button which I just clicked.
How does this work? I thought when the field got focus that would be the
active control. How can I solve it so that it will return the name of the
field the code is in?

Private Sub MyFirstField_GotFocus()

Dim ctl As Control
Set ctl = Screen.ActiveControl
InfoField = ctl.Name

End Sub

Thanks,
john
Jun 22 '07 #1
6 1790
ARC
In the button that opens form b, you might want to put 2 set focus commands:

Forms!formb.setfocus
forms!formb.form![ctrlname].setfocus

"John" <jo@hn.comwrote in message
news:f5***********@textnews.wanadoo.nl...
Following code belongs to the first field in form B. When I open form B
from form A, ctl.Name returns the name of Form's A button which I just
clicked. How does this work? I thought when the field got focus that would
be the active control. How can I solve it so that it will return the name
of the field the code is in?

Private Sub MyFirstField_GotFocus()

Dim ctl As Control
Set ctl = Screen.ActiveControl
InfoField = ctl.Name

End Sub

Thanks,
john

Jun 22 '07 #2
Thanks,

Forms!formb.setfocus works fine.

The problem now is that the name of the form is looked up in a table, so I
have it in a string value. I tried every possible reference without luck:

Forms!strMyString.setfocus
Forms(strMyString).setfocus
Forms![strMyString].setfocus

What am I doing wrong???
john

"ARC" <an**@andyc.comschreef in bericht
news:Eo******************@newssvr23.news.prodigy.n et...
In the button that opens form b, you might want to put 2 set focus
commands:

Forms!formb.setfocus
forms!formb.form![ctrlname].setfocus

"John" <jo@hn.comwrote in message
news:f5***********@textnews.wanadoo.nl...
>Following code belongs to the first field in form B. When I open form B
from form A, ctl.Name returns the name of Form's A button which I just
clicked. How does this work? I thought when the field got focus that
would be the active control. How can I solve it so that it will return
the name of the field the code is in?

Private Sub MyFirstField_GotFocus()

Dim ctl As Control
Set ctl = Screen.ActiveControl
InfoField = ctl.Name

End Sub

Thanks,
john


Jun 22 '07 #3
John wrote:
>Following code belongs to the first field in form B. When I open form B from
form A, ctl.Name returns the name of Form's A button which I just clicked.
How does this work? I thought when the field got focus that would be the
active control. How can I solve it so that it will return the name of the
field the code is in?

Private Sub MyFirstField_GotFocus()

Dim ctl As Control
Set ctl = Screen.ActiveControl
InfoField = ctl.Name

End Sub

That seems a little odd, but I'd rather not trust the Screen
object to know which form is the active form so early in the
transition. Try using Me.ActiveControl

--
Marsh
Jun 23 '07 #4
ARC
How about this?

forms(strMyString).Name.setfocus


"John" <jo@hn.comwrote in message
news:f5***********@textnews.wanadoo.nl...
Thanks,

Forms!formb.setfocus works fine.

The problem now is that the name of the form is looked up in a table, so I
have it in a string value. I tried every possible reference without luck:

Forms!strMyString.setfocus
Forms(strMyString).setfocus
Forms![strMyString].setfocus

What am I doing wrong???
john

"ARC" <an**@andyc.comschreef in bericht
news:Eo******************@newssvr23.news.prodigy.n et...
>In the button that opens form b, you might want to put 2 set focus
commands:

Forms!formb.setfocus
forms!formb.form![ctrlname].setfocus

"John" <jo@hn.comwrote in message
news:f5***********@textnews.wanadoo.nl...
>>Following code belongs to the first field in form B. When I open form B
from form A, ctl.Name returns the name of Form's A button which I just
clicked. How does this work? I thought when the field got focus that
would be the active control. How can I solve it so that it will return
the name of the field the code is in?

Private Sub MyFirstField_GotFocus()

Dim ctl As Control
Set ctl = Screen.ActiveControl
InfoField = ctl.Name

End Sub

Thanks,
john



Jun 23 '07 #5
ARC
Actually, I think the last post won't work. Here's another to try:
Forms(StrMyString).Form.setfocus

"ARC" <an**@andyc.comwrote in message
news:pb*****************@newssvr22.news.prodigy.ne t...
How about this?

forms(strMyString).Name.setfocus


"John" <jo@hn.comwrote in message
news:f5***********@textnews.wanadoo.nl...
>Thanks,

Forms!formb.setfocus works fine.

The problem now is that the name of the form is looked up in a table, so
I have it in a string value. I tried every possible reference without
luck:

Forms!strMyString.setfocus
Forms(strMyString).setfocus
Forms![strMyString].setfocus

What am I doing wrong???
john

"ARC" <an**@andyc.comschreef in bericht
news:Eo******************@newssvr23.news.prodigy. net...
>>In the button that opens form b, you might want to put 2 set focus
commands:

Forms!formb.setfocus
forms!formb.form![ctrlname].setfocus

"John" <jo@hn.comwrote in message
news:f5***********@textnews.wanadoo.nl...
Following code belongs to the first field in form B. When I open form B
from form A, ctl.Name returns the name of Form's A button which I just
clicked. How does this work? I thought when the field got focus that
would be the active control. How can I solve it so that it will return
the name of the field the code is in?

Private Sub MyFirstField_GotFocus()

Dim ctl As Control
Set ctl = Screen.ActiveControl
InfoField = ctl.Name

End Sub

Thanks,
john



Jun 23 '07 #6
Thanks. I got it working.
john

"ARC" <an**@andyc.comschreef in bericht
news:Hm*****************@newssvr22.news.prodigy.ne t...
Actually, I think the last post won't work. Here's another to try:
Forms(StrMyString).Form.setfocus

"ARC" <an**@andyc.comwrote in message
news:pb*****************@newssvr22.news.prodigy.ne t...
>How about this?

forms(strMyString).Name.setfocus


"John" <jo@hn.comwrote in message
news:f5***********@textnews.wanadoo.nl...
>>Thanks,

Forms!formb.setfocus works fine.

The problem now is that the name of the form is looked up in a table, so
I have it in a string value. I tried every possible reference without
luck:

Forms!strMyString.setfocus
Forms(strMyString).setfocus
Forms![strMyString].setfocus

What am I doing wrong???
john

"ARC" <an**@andyc.comschreef in bericht
news:Eo******************@newssvr23.news.prodigy .net...
In the button that opens form b, you might want to put 2 set focus
commands:

Forms!formb.setfocus
forms!formb.form![ctrlname].setfocus

"John" <jo@hn.comwrote in message
news:f5***********@textnews.wanadoo.nl...
Following code belongs to the first field in form B. When I open form
B from form A, ctl.Name returns the name of Form's A button which I
just clicked. How does this work? I thought when the field got focus
that would be the active control. How can I solve it so that it will
return the name of the field the code is in?
>
Private Sub MyFirstField_GotFocus()
>
Dim ctl As Control
Set ctl = Screen.ActiveControl
InfoField = ctl.Name
>
End Sub
>
Thanks,
john
>




Jun 23 '07 #7

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

Similar topics

7
by: Jonas | last post by:
This works fine in Win XP but does not work at all in Win 98. Private WithEvents objIExplorer As InternetExplorer I have to do it like this to get it to work in Win 98 Dim objIExplorer As...
3
by: Julian | last post by:
Hi I am trying to update a date field in my table but some how this simple code does not work, I know the select work because if I write the fields, it will show the data from the table but why...
5
by: me | last post by:
I have a Class Library that contains a Form and several helper classes. A thread gets created that performs processing of data behind the scenes and the Form never gets displayed (it is for debug...
22
by: Robert Bralic | last post by:
CAN anybody tell me any address where I can download some small(1000-2000) lines C++ proghram source. Or send me ,a small(1000-2000) lines C++ program source that I can compille with gpp under...
12
by: Frank Hauptlorenz | last post by:
Hello Out there! I have a DB2 V7.2 Database (Fix11) on Win 2000 Professional. It was before a NT 4 based Domain - now it is a Win 2000 Domain. The database server is a domain member. Now...
0
by: Jarod_24 | last post by:
How does tabindex work in ASP .net pages I dosen't seem to work quite like in regular forms. and there isn't any TabStop property either. 1 .How do you prevent a control form beign "tabbed"....
14
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it...
89
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be...
14
by: webEater | last post by:
I have a problem, it's not browser specific, and I don't get a solution. I have an (X)HTML document, I show you a part of it: .... <!--<div class="pad">--> <div id="eventImages"><img src=""...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.