Go To Control Evading Tab Order

T

TravelingHT

I am trying to get a "Yes/No" Combo box result to initiate a GoToControl. No
luck.
This is what I have so far:-

Private Sub EverHiredTemporaryHistologist_Exit(Cancle As Integer)
If Me.EverHiredTemporaryHistologists = "No" Then
DoCmd.GoToControl(Me.HRPersonability).SetFocus

ElseIf Me.EverHiredTemporaryHistologists = "Yes" Then
DoCmd.GoToControl(Me.HRRelationshipSpeed).SetFocus
End If
End Sub

No errors or anything. I am starting to think the first line is the problem.
Both controls are in the same form.
This whole (Cancle As Integer) or () I am not sure how I decied what to use?

Thanks in Advance

--
Anthony Williams
Histotech Exchange LLC
19 Whitmore St.
Lexington, VA 24450
(e-mail address removed)
 
S

strive4peace

Hi Anthony,

are you sure you want to do this? Perhaps it might be better to change
the TAB ORDER of the form...

At any rate, try this:

'~~~~~~~~~~~~~~~~~~
Me.HRRelationshipSpeed.SetFocus
'~~~~~~~~~~~~~~~~~~


Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*
 
M

Mr B

TravelingHT,

Try using the AfterUpdate event of your check box instead of the OnExit
event.

You can then use something like (air code):

If Me.NameOfCheckbox = True Then
Me.NameOfTextBox.SetFocus
Else
Me.NameOfOtherTextbox.SetFocus
End If

You should not have to use the DoCmd.GoToControl method.
 
T

TravelingHT

Dear Crystal:

Thanks for your help.

I added your code so the whole thing looks like this:

Private Sub EverHiredTemporaryHistologist_LostFocus()
If Me.EverHiredTemporaryHistologists = "No" Then
Me.HRPersonability.SetFocus

ElseIf Me.EverHiredTemporaryHistologists = "Yes" Then
Me.HRRelationshipSpeed.SetFocus
End If
End Sub

No Dice, nothing happens. I think I am in the worng chat room I need to be
in the New Users chat room from now on.

I want to use the yes no combo becuase I acutally want to use it to set
focus on a control in a sub form, but I need to be able to get this to work
first in this form then I can worry about trying to figure out the second part

So if you have any ideas I am all ears.

Thanks in advance.
 
S

strive4peace

Hi Anthony,

you're welcome

If EverHiredTemporaryHistologists is a yes/no field, you need to change
your comparison to something like this:

If Me.EverHiredTemporaryHistologists = False then

"want to use it to set focus on a control in a sub form"

is the control you are setting the focus to on the same for as the code?

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*
 
T

TravelingHT

Dear Mr. B (That makes me Baldrick (British TV))

Thanks for your help but no beans.
I am not sure if the fact that I set up the "Yes/No" combo box "Row Source
Type as a "List Value" Yes;No makes any difference.

I tried this code first.
NO BEANS

Private Sub EverHiredTemporaryHistologists_AfterUpdate()
If Me.EverHiredTemporaryHistologists = "Yes" Then
Me.HRPersonability.SetFocus

ElseIf Me.EverHiredTemporaryHistologists = "No" Then
Me.HRRelationshipSpeed.SetFocus
End If
End Sub

Then I tried this, seeing I had not followed your instructions the first
time. (I did put in True without ("") first then tried it with the "Yes"

Private Sub EverHiredTemporaryHistologists_AfterUpdate()
If Me.EverHiredTemporaryHistologists = "Yes" Then
Me.HRPersonability.SetFocus

Else: Me.HRRelationshipSpeed.SetFocus
End If
End Sub

Intrestingly it did take the focus on update to the next control in the tab
order after update, but never did it move to where I want it to go. One of
the choices above in the If statement is the next in the tab order. So I am
going to swap in another control to see if that makes any difference.

Keep on keeping on.

Thanks in advance.

TravelingHT
 
T

TravelingHT

Dear Mr. B

OK I tried a varient on what you gave me and it is working I had to
substitute "Yes" for "True". Works with Yes but not True.

Also because it is OnUpdate, and the tab order is actually the choice for
the defalt value I have no problem even if I do not update the value, but for
anyone else out there who is trying this you can have a defalt value that you
do not update and thus can have 3 choices of where to send the focus.

The code I am using is this:

Private Sub EverHiredTemporaryHistologists_AfterUpdate()
If Me.EverHiredTemporaryHistologists = "Yes" Then
Me.HRPersonability.SetFocus

Else: Me.HRRelationshipSpeed.SetFocus
End If
End Sub

It will not work with True instead of "Yes" go figure.

Thanks lot, Much apreciated.
 
T

TravelingHT

Dear Crystal:

Thanks for your help.

OK I tried a varient on what you gave me and it is working I had to
substitute "Yes" for "True". Works with Yes but not True.

Also because the code works OnUpdate (so only comes into play if you
change the value in the control) and the defalt value(Which is "No") the
underlying tab order is also the choice for the defalt value I have no
problem even if I do not update the value because the result is the same.
So doing nothing makes the next control with focus x
Putting in "No" makes the next control with focus x
Putting in "Yes" makes the next control with focus y

For anyone else out there who is trying this you can have a defalt value
that you do not update and thus can have 3 choices of where to send the focus
after tab.

The code I am using is this:

Private Sub EverHiredTemporaryHistologists_AfterUpdate()
If Me.EverHiredTemporaryHistologists = "Yes" Then
Me.HRPersonability.SetFocus

Else: Me.HRRelationshipSpeed.SetFocus
End If
End Sub

It will not work with True instead of "Yes" go figure.

Thanks lot, Much apreciated.

As for the subform, I have used up enough help and time from you lot for
now. I have a bunch of stuff that I asked in earlier questions. I need to
spend the time going through it and trying to figure it out.

I did take a look at your 8 part free tutorial, I saw the link in the
earlier post on this question.
It was very infomative, I apreciate the time you took creating
it. A valuable resource for anyone.

I have taken some notes and added that to my 4 pages of info I have so far
collected. You may see a post tomorrow. I will work on them and, if I get
success add to the end of this string of posts.

Thank you again.

Traveling Tech.
 
T

TravelingHT

OK so noone may read this but if you do and find it helpfull I am very happy
for you.

So my original problem was trying to alter the tab order depending on the
response from a combo box.

I set the values as Yes;No in the "Row Source" (Found in the Properties list
about 5 to 8 down in the All tab) The preceding note is only inclued as it
may be important only to the fact that the If value "Yes" in the following
code works, it may be that the "Yes" is normally True, or False, depending
on your needs.

In the code in the latest ones by me, you can see code that works and will
change the tab order within a form.

Now here is code that will take the tab to a sub form if the If statment
gets the right value:

Private Sub ControlName_AfterUpdate()
If Me.ControlName = "Yes" Then
Forms!FormName.SubformName.SetFocus

Else: Me.ControlName.SetFocus
End If
End Sub

The important thing to note is this.
This only takes the focus to the sub form, but once there you can simply set
the tab order that you want on the underlying form. (NOTE it is apparently
not a good idea to work on a form in the subform mode. )
You do not need, OK you may want it to start in different places etc, but
you can write the code in the form.

If anyone wants to propose the last line of code to follow this line to alow
you to directly SetFocus, please by all means be my guest.

Private Sub ControlName_AfterUpdate()
If Me.ControlName = "Yes" Then
Forms!FormName.SubformName.SetFocus
YOUR LINE OF CODE GOES HERE!

Thanks in advance to all those who helped me I much apreciated it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top