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:53 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, 03:27 PM posted to microsoft.public.access.forms
Trini Gal
external usenet poster
 
Posts: 20
Default SetFocus

I am so sorry, for some reason, I kept getting an error that my question
wasn't posted so I kept trying. I just noticed that the posts did in fact go
through and I have multiple posts of the same thing, again, I'm so sorry.

"Trini Gal" wrote:

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.

  #3  
Old July 24th, 2009, 06:27 AM posted to microsoft.public.access.forms
Steve Sanford
external usenet poster
 
Posts: 190
Default SetFocus

Nothing wrong with the code. It is doing exactly what you are saying to do.

You have said "If the action combo is 'Change', then set the focus to the
Current_CHL (text box), then set the focus to the New_CHL (text box). You
just can't see the focus being set to the Current_CHL (text box) because it
has the focus for only a small fraction of a second.

If you want the focus to stop at the Current_CHL (text box), allow you to
make changes, then move to New_CHL (text box), you will have to change your
code.

Setting the TAB stops to NO only affects which controls will receive the
focus when the TAB BUTTON on the keyboard is pushed (if the control is
Enabled and not Locked).


My personal preference would be to use "Select Case" function instead of the
"IF" function. Easier to read and modify (IMO)..........

'---------------------------------------
Private Sub Action_AfterUpdate()

Select Case Me.Action
Case "Add"
Me.New_CHL.SetFocus

Case "Change"
Me.Current_CHL.SetFocus
Me.New_CHL.SetFocus

Case "Drop"
Me.Current_CHL.SetFocus

Case Else
MsgBox "How did I get here??? Must be an ERROR!!!"
End Select

End Sub
'---------------------------------------

HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


"Trini Gal" wrote:

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.

 




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 07:30 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.