472,128 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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 GetPreviousRecord 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 GetPreviousRecord 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 8758
You can use the ActiveControl property of the Screen object to figure out
which button was just pressed. Here is an example:
If Screen.ActiveControl.Name = "cmdPreviousRecord" 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.PreviousControl 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*****@designid.com> wrote in message
news:1b*************************@posting.google.co m...
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 GetPreviousRecord 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 GetPreviousRecord 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.ActiveControl.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*******@goodwill-suncoast.com> wrote in message news:<7M*****************@twister.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.ActiveControl.Name = "cmdPreviousRecord" Then
.
. ' Do something here
.
ElseIf Screen.ActiveControl.Name = "txtCustomerName" Then
.
. ' Do something else.
.
End If

Hope this helps.
"MJW" <mw*****@designid.com> wrote in message
news:1b*************************@posting.google.co m...
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 GetPreviousRecord 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 GetPreviousRecord 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********************@news-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.PreviousControl 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*****@designid.com> wrote in message
news:1b*************************@posting.google.co m...
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 GetPreviousRecord 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 GetPreviousRecord 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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Randi | last post: by
6 posts views Thread by Sally | last post: by
4 posts views Thread by Rochdi | last post: by
reply views Thread by Demetri | last post: by
reply views Thread by leo001 | last post: by

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.