A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

SetFocus



 
 
Thread Tools Display Modes
  #1  
Old July 23rd, 2009, 02:11 PM posted to microsoft.public.access.forms
Trini Gal
external usenet poster
 
Posts: 20
Default SetFocus

Hello,

I have a form with a combo box and two text boxes. Depending on the
selection the user makes I want the cursor to move to one of the text box.

Action (combo box) Current_CHL (text box) New_CHL (text box)
Add - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Change - - - - - - - - - - - - - - - - - - - - - - - - -
Drop - - - - - - - - - - - - - -

I have this code attached to the Action Combo:

Private Sub Action_AfterUpdate()

If Me.Action = "Add" Then
Me.New_CHL.SetFocus
ElseIf Me.Action = "Change" Then
Me.Current_CHL.SetFocus
Me.New_CHL.SetFocus
ElseIf Me.Action = "Drop" Then
Me.Current_CHL.SetFocus
End If

End Sub
The "Add" and "Drop" works, but for some reason, I can't figure out why the
"Change" not working. It got to the New_CHL not the Current_CHL. I have the
tab stops for both New_CHL and Current_CHL set to no.

Can someone help me out, thanks.

  #2  
Old July 23rd, 2009, 02:31 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default SetFocus

"Trini Gal" wrote in message
...
Hello,

I have a form with a combo box and two text boxes. Depending on the
selection the user makes I want the cursor to move to one of the text box.

Action (combo box) Current_CHL (text box) New_CHL (text box)
Add - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Change - - - - - - - - - - - - - - - - - - - - - - - - -
Drop - - - - - - - - - - - - - -

I have this code attached to the Action Combo:

Private Sub Action_AfterUpdate()

If Me.Action = "Add" Then
Me.New_CHL.SetFocus
ElseIf Me.Action = "Change" Then
Me.Current_CHL.SetFocus
Me.New_CHL.SetFocus
ElseIf Me.Action = "Drop" Then
Me.Current_CHL.SetFocus
End If

End Sub
The "Add" and "Drop" works, but for some reason, I can't figure out why
the
"Change" not working. It got to the New_CHL not the Current_CHL. I have
the
tab stops for both New_CHL and Current_CHL set to no.

Can someone help me out, thanks.



What is the purpose of setting the focus first to Current_CHL, and then
immediately to New_CHL? Are you running some code in the GotFocus of
Current_CHL? If so, it would make more sense just to call the control's
GotFocus event procedure directly, rather than actually sending the focus
the

ElseIf Me.Action = "Change" Then
Call Current_CHL_GotFocus
Me.New_CHL.SetFocus

However, I'm not sure why the focus wouldn't be reaching Current_CHL with
your current code. Are you sure it isn't getting there, even momentarily?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

  #3  
Old July 23rd, 2009, 03:24 PM posted to microsoft.public.access.forms
Trini Gal
external usenet poster
 
Posts: 20
Default SetFocus

I'm not running any other code. Also, I'm sure, its not going to Current_CHL
at all, it just goes to New_CHL. The dept. that I'm building the database
for wants to limit the users access to fields. So depending on the
selection, they want the user to go to only certain fields. If there is a
change, they want to know what the Current_CHL is and then what it will be
after the approval process is done. Is there any other way of doing this?

"Dirk Goldgar" wrote:

"Trini Gal" wrote in message
...
Hello,

I have a form with a combo box and two text boxes. Depending on the
selection the user makes I want the cursor to move to one of the text box.

Action (combo box) Current_CHL (text box) New_CHL (text box)
Add - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Change - - - - - - - - - - - - - - - - - - - - - - - - -
Drop - - - - - - - - - - - - - -

I have this code attached to the Action Combo:

Private Sub Action_AfterUpdate()

If Me.Action = "Add" Then
Me.New_CHL.SetFocus
ElseIf Me.Action = "Change" Then
Me.Current_CHL.SetFocus
Me.New_CHL.SetFocus
ElseIf Me.Action = "Drop" Then
Me.Current_CHL.SetFocus
End If

End Sub
The "Add" and "Drop" works, but for some reason, I can't figure out why
the
"Change" not working. It got to the New_CHL not the Current_CHL. I have
the
tab stops for both New_CHL and Current_CHL set to no.

Can someone help me out, thanks.



What is the purpose of setting the focus first to Current_CHL, and then
immediately to New_CHL? Are you running some code in the GotFocus of
Current_CHL? If so, it would make more sense just to call the control's
GotFocus event procedure directly, rather than actually sending the focus
the

ElseIf Me.Action = "Change" Then
Call Current_CHL_GotFocus
Me.New_CHL.SetFocus

However, I'm not sure why the focus wouldn't be reaching Current_CHL with
your current code. Are you sure it isn't getting there, even momentarily?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

  #4  
Old July 23rd, 2009, 04:26 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default SetFocus

"Trini Gal" wrote in message
...
I'm not running any other code. Also, I'm sure, its not going to
Current_CHL
at all, it just goes to New_CHL. The dept. that I'm building the database
for wants to limit the users access to fields. So depending on the
selection, they want the user to go to only certain fields. If there is a
change, they want to know what the Current_CHL is and then what it will be
after the approval process is done. Is there any other way of doing this?


I'm sorry, I don't understand you. If no code is running, how would you
ever know whether the focus went first to Current_CHL and then immediately
to New_CHL, or whether it skipped it? By the time you could possibly see
it, the focus would be on New_CHL. What do you expect to happen when the
focus passes oh-so-briefly through Current_CHL?

Setting the focus won't control where the user can go, only where they are
now. Even if a control is not in the tab order, a user can still click on
it to move the focus there, so long as the control is enabled and visible.
Maybe you should be controlling the visibility of the controls, rather than
setting the focus. But as I said, I don't understand what you are trying to
achieve, because your use of SetFocus doesn't seem to make sense in the
context of what you said above.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:09 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.