473,569 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking For Click Event of Command Button During LostFocus Event

MJW
Is there a way for me to know if or which command button was just
clicked that triggers the LostFocus event for the current control on a
Form?

I have a form that has many types of users who each have their own set
of fields they can change. Therefore I use setfocus property in the
lostfocus event for some of the users to get from one control to
another. Since I am "directing traffic" with setfocus, the users are
unable to use the record navigation buttons I created to go back and
forth between records. The user presses the GetPreviousReco rd button,
the lostfocus event of the current control is triggered, and the
setfocus code forces the user to the next control ignoring that the
user wants to go to the next record. How can I determine that I
pressed the GetPreviousReco rd button so I can go to the previous
record and ignore the setfocus code for the next control?

From MS help under lostfocus event:
If you move the focus to a control on a form, and that control doesn't
have the focus on that form, the Exit and LostFocus events for the
control that does have the focus on the form occur before the Enter
and GotFocus events for the control you moved to.

Is there anyway I can see the control that is going to get the Enter
Event before exiting the current control?

Thanks for your help!
Nov 12 '05 #1
4 8930
You can use the ActiveControl property of the Screen object to figure out
which button was just pressed. Here is an example:
If Screen.ActiveCo ntrol.Name = "cmdPreviousRec ord" Then
Nov 12 '05 #2
There is no way to know which control is about to receive focus.

Once focus has moved to the command button, Screen.Previous Control will tell
you where it came from.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"MJW" <mw*****@design id.com> wrote in message
news:1b******** *************** **@posting.goog le.com...
Is there a way for me to know if or which command button was just
clicked that triggers the LostFocus event for the current control on a
Form?

I have a form that has many types of users who each have their own set
of fields they can change. Therefore I use setfocus property in the
lostfocus event for some of the users to get from one control to
another. Since I am "directing traffic" with setfocus, the users are
unable to use the record navigation buttons I created to go back and
forth between records. The user presses the GetPreviousReco rd button,
the lostfocus event of the current control is triggered, and the
setfocus code forces the user to the next control ignoring that the
user wants to go to the next record. How can I determine that I
pressed the GetPreviousReco rd button so I can go to the previous
record and ignore the setfocus code for the next control?

From MS help under lostfocus event:
If you move the focus to a control on a form, and that control doesn't
have the focus on that form, the Exit and LostFocus events for the
control that does have the focus on the form occur before the Enter
and GotFocus events for the control you moved to.

Is there anyway I can see the control that is going to get the Enter
Event before exiting the current control?

Thanks for your help!

Nov 12 '05 #3
MJW
Thank you for responding. This will not work for me in this case
because I want to know which command button was pressed that triggers
the lostfocus event of the current control (textbox) that I am in. so
Screen.ActiveCo ntrol.Name will tell me the name of the control that I
am currently on, not the command button I just pressed (I tried this
before I sent the post.)

"Tom marsh" <le*******@good will-suncoast.com> wrote in message news:<7M******* **********@twis ter.tampabay.rr .com>...
You can use the ActiveControl property of the Screen object to figure out
which button was just pressed. Here is an example:
If Screen.ActiveCo ntrol.Name = "cmdPreviousRec ord" Then
.
. ' Do something here
.
ElseIf Screen.ActiveCo ntrol.Name = "txtCustomerNam e" Then
.
. ' Do something else.
.
End If

Hope this helps.
"MJW" <mw*****@design id.com> wrote in message
news:1b******** *************** **@posting.goog le.com...
Is there a way for me to know if or which command button was just
clicked that triggers the LostFocus event for the current control on a
Form?

I have a form that has many types of users who each have their own set
of fields they can change. Therefore I use setfocus property in the
lostfocus event for some of the users to get from one control to
another. Since I am "directing traffic" with setfocus, the users are
unable to use the record navigation buttons I created to go back and
forth between records. The user presses the GetPreviousReco rd button,
the lostfocus event of the current control is triggered, and the
setfocus code forces the user to the next control ignoring that the
user wants to go to the next record. How can I determine that I
pressed the GetPreviousReco rd button so I can go to the previous
record and ignore the setfocus code for the next control?

From MS help under lostfocus event:
If you move the focus to a control on a form, and that control doesn't
have the focus on that form, the Exit and LostFocus events for the
control that does have the focus on the form occur before the Enter
and GotFocus events for the control you moved to.

Is there anyway I can see the control that is going to get the Enter
Event before exiting the current control?

Thanks for your help!

Nov 12 '05 #4
MJW
That is what I was afraid of. Since my lostfocus event has a setfocus
to a different textbox, the command button pressed is ignored and the
focus moves to the textbox instead.

Thanks for responding.
"Allen Browne" <ab************ ***@bigpond.net .au> wrote in message news:<uH******* *************@n ews-server.bigpond. net.au>...
There is no way to know which control is about to receive focus.

Once focus has moved to the command button, Screen.Previous Control will tell
you where it came from.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"MJW" <mw*****@design id.com> wrote in message
news:1b******** *************** **@posting.goog le.com...
Is there a way for me to know if or which command button was just
clicked that triggers the LostFocus event for the current control on a
Form?

I have a form that has many types of users who each have their own set
of fields they can change. Therefore I use setfocus property in the
lostfocus event for some of the users to get from one control to
another. Since I am "directing traffic" with setfocus, the users are
unable to use the record navigation buttons I created to go back and
forth between records. The user presses the GetPreviousReco rd button,
the lostfocus event of the current control is triggered, and the
setfocus code forces the user to the next control ignoring that the
user wants to go to the next record. How can I determine that I
pressed the GetPreviousReco rd button so I can go to the previous
record and ignore the setfocus code for the next control?

From MS help under lostfocus event:
If you move the focus to a control on a form, and that control doesn't
have the focus on that form, the Exit and LostFocus events for the
control that does have the focus on the form occur before the Enter
and GotFocus events for the control you moved to.

Is there anyway I can see the control that is going to get the Enter
Event before exiting the current control?

Thanks for your help!

Nov 12 '05 #5

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

Similar topics

3
9417
by: Randi | last post by:
Hi All, I have a problem on a username password login form. I use: txtPassword.Text = StrConv(txtPassword.Text, vbProperCase) to validate the proper case when someone enters their name and password. It work when you use the button to continue, but if you hit enter on your keyboard the event apparently doesnt lose focus and it says you...
7
2764
by: Marina | last post by:
Imagine a form with some fields and an OK buttons that saves the information. Each field has validation logic in the Validating event. If the input is not valid, the control's value is replaced with the last value it had before the user changed it. Pretty typical Now, the user types some invalid value and clicks OK. The user gets a...
6
3925
by: Sally | last post by:
I need to be able to click in a subform and run code but at the same time I need to be able to scroll the records without running the code. I tried coding the Enter event of the subform control but when I try to scroll the records the code runs. The subform is continuous; all the controls are on one line and the detail section is not exsposed...
7
1411
by: Mrkrich | last post by:
I have one procedure that will take very long time before it finishs. During its running, I provide users a button to cancel this process if they don't want it to run anymore. I have one varible for process status if user click the cancel button this variable will change to False and the procedure will check this variable during it run ...
4
1463
by: Rochdi | last post by:
Hi guys, I'm using the VS 2002 version and for a TextBox, I've selected the Textbox control from the left combo in the code page and I've seen many events but I couldn't find the Click, GotFocus or LostFocus events like in VB6, and if I type the event like: Private Sub TextBox1_Click(.......)TextBox1.Click End Sub it is working!!! So how...
3
3823
by: Tom | last post by:
I have a VB .NET application that has a text box with the following code to handle the leave event. Private Sub txtIDiscountRate_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtIDiscountRate.Leave If txtIDiscountRate.Text.Trim <> "" AndAlso _ MsgBox("Are you sure you want to use a non- default discount...
2
5368
by: Simon Verona | last post by:
I have a usercontrol with code in the "leave" event which updates the final data back into a database. This works fine except if I have a default "accept" button on a form and invoke it by pressing the ENTER key on the keyboard. In this case, it would appear that whilst the code on the button is executing and therefore presumably the...
0
2938
by: Demetri | last post by:
I have created a web control that can be rendered as either a linkbutton or a button. It is a ConfirmButton control that allows a developer to force a user to confirm if they intended to click it such as when they do a delete. Everything is great. By and large it will be used in my repeater controls using the command event when the user...
14
14586
by: teddysnips | last post by:
WINDOWS FORMS I've a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user presses the "Save" button while the textbox has the focus, the LostFocus code doesn't run at the right time, so that the "Save" function is dealing with...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7974
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
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 we have to send another system

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.