Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Statement with SetFocus

Status
Not open for further replies.

TriniGal

Programmer
Sep 28, 2005
84
US
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:

Code:
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 goes 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.
 
In the change portion of the code you set focus to the Current_CHL and then instantly set focus to the New_CHL.

Try this see if it works for you:
Code:
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
Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
HarleyQuinn,

Nope, that didn't work. That makes it go to the Current_CHL and that it, does not go to NEW_CHL. Any other ideas?

Thanks,
 
Is there something that fires when the controls get focus that you need it to hit both?

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
No, nothing else.

Basically, if there is a change, I need to know what the channel # is right now, and what it will be after the change.
 
So why the need to set focus at all? Why not use .Value?

Your code in the first instance did exactly what you said it needed to (i.e. it set focus to the Current and then setfocus to the New).

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Thanks for your help I figured it out. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top