By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,573 Members | 938 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,573 IT Pros & Developers. It's quick & easy.

Setting focus after selection in combo box?

P: n/a
Orv
I have a "Yes/No" combo box (set to required) and I want the focus to shift
to differnet controls (on the same form) based on the selection of "Yes" or
"No". Would this have to be placed on the "Exit" event?

I tried Google...and no luck.
I'm sure there's gonna be an "If" statement involved.

TIA,
-Orv
Access2003
Oct 25 '08 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hello.

You have a couple of choices of where to put this. I would probably put
it in the AfterUpdate event, because this should set the focus to the
next control as soon as a value is selected from the list. Putting it in
the OnExit event would work, but the focus wouldn't shift to the
specified control until the user exits the combo box.

It would probably look something like this:

Private Sub Combo0_AfterUpdate()

If Combo0.Value = "Yes" then
Control1.SetFocus
Else
Control2.SetFocus
End If

End Sub

Orv wrote:
I have a "Yes/No" combo box (set to required) and I want the focus to shift
to differnet controls (on the same form) based on the selection of "Yes" or
"No". Would this have to be placed on the "Exit" event?

I tried Google...and no luck.
I'm sure there's gonna be an "If" statement involved.

TIA,
-Orv
Access2003

Oct 25 '08 #2

P: n/a
On Sat, 25 Oct 2008 00:28:33 -0400, Orv wrote:
I have a "Yes/No" combo box (set to required) and I want the focus to shift
to differnet controls (on the same form) based on the selection of "Yes" or
"No". Would this have to be placed on the "Exit" event?

I tried Google...and no luck.
I'm sure there's gonna be an "If" statement involved.

TIA,
-Orv
Access2003
Code the Combo Box's AfterUpdate event:
If Me![ComboName] = "Yes" Then
Me![ControlA].SetFocus
Else
Me![ControlB].SetFocus
End If
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Oct 25 '08 #3

P: n/a
Orv
Thanks for the quick help.
I can't get either of the examples to work.
They both go to the next control.

I tried a simple testDB with only the 3 controls (flat DB and it still went
to the next control) instead of the "Yes/No" being pulled from seperate tbl.
I know I'm making this harder than it is.

"fredg" <fg******@example.invalidwrote in message
news:gg*****************************@40tude.net...
On Sat, 25 Oct 2008 00:28:33 -0400, Orv wrote:
>I have a "Yes/No" combo box (set to required) and I want the focus to
shift
to differnet controls (on the same form) based on the selection of "Yes"
or
"No". Would this have to be placed on the "Exit" event?

I tried Google...and no luck.
I'm sure there's gonna be an "If" statement involved.

TIA,
-Orv
Access2003

Code the Combo Box's AfterUpdate event:
If Me![ComboName] = "Yes" Then
Me![ControlA].SetFocus
Else
Me![ControlB].SetFocus
End If
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


Oct 25 '08 #4

P: n/a
On Sat, 25 Oct 2008 07:31:08 -0400, Orv wrote:
Thanks for the quick help.
I can't get either of the examples to work.
They both go to the next control.

I tried a simple testDB with only the 3 controls (flat DB and it still went
to the next control) instead of the "Yes/No" being pulled from seperate tbl.
I know I'm making this harder than it is.

"fredg" <fg******@example.invalidwrote in message
news:gg*****************************@40tude.net...
>On Sat, 25 Oct 2008 00:28:33 -0400, Orv wrote:
>>I have a "Yes/No" combo box (set to required) and I want the focus to
shift
to differnet controls (on the same form) based on the selection of "Yes"
or
"No". Would this have to be placed on the "Exit" event?

I tried Google...and no luck.
I'm sure there's gonna be an "If" statement involved.

TIA,
-Orv
Access2003

Code the Combo Box's AfterUpdate event:
If Me![ComboName] = "Yes" Then
Me![ControlA].SetFocus
Else
Me![ControlB].SetFocus
End If
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
1) What do you mean by "Yes/No pulled from a separate table"?
2) What is the EXACT rowsource of the Combo Box?
3) What is the Combo Box Bound Column?
4) What is the Combo Box Column Count?
4) Did you change [ComboName] to the actual name of your combo box?
5) Are you sure the Text value of "Yes" or "No" shown in the combo box
is the bound column value?

Try this:

If Me![ComboName] = -1 Then
Me![ControlA].SetFocus
Else
Me![ControlB].SetFocus
End If

6) Did you change ControlA and ControlB to the names of your actual
controls?
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Oct 25 '08 #5

P: n/a
Orv
Ok...finally!

I had the Bound Column set to 1, not 2. This is what worked:

If Me!ComboName = 1 Then
Me!ContolA.SetFocus
Else
Me!ControlB.SetFocus
End If

What I meant by "Yes/No" in a seperate tbl is that I have a tbl named
tblYesNo with pkYN(Autonumber) and fkYN, with 1st row "Yes" and 2nd row
"No". I then place my combo box on form from the field (I need a Yes/No for)
and have it store that value in the field in my main tbl.

Not sure if I explained it correctly.

End Sub
"fredg" <fg******@example.invalidwrote in message
news:pb*****************************@40tude.net...
On Sat, 25 Oct 2008 07:31:08 -0400, Orv wrote:
>Thanks for the quick help.
I can't get either of the examples to work.
They both go to the next control.

I tried a simple testDB with only the 3 controls (flat DB and it still
went
to the next control) instead of the "Yes/No" being pulled from seperate
tbl.
I know I'm making this harder than it is.

"fredg" <fg******@example.invalidwrote in message
news:gg*****************************@40tude.net.. .
>>On Sat, 25 Oct 2008 00:28:33 -0400, Orv wrote:

I have a "Yes/No" combo box (set to required) and I want the focus to
shift
to differnet controls (on the same form) based on the selection of
"Yes"
or
"No". Would this have to be placed on the "Exit" event?

I tried Google...and no luck.
I'm sure there's gonna be an "If" statement involved.

TIA,
-Orv
Access2003

Code the Combo Box's AfterUpdate event:
If Me![ComboName] = "Yes" Then
Me![ControlA].SetFocus
Else
Me![ControlB].SetFocus
End If
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

1) What do you mean by "Yes/No pulled from a separate table"?
2) What is the EXACT rowsource of the Combo Box?
3) What is the Combo Box Bound Column?
4) What is the Combo Box Column Count?
4) Did you change [ComboName] to the actual name of your combo box?
5) Are you sure the Text value of "Yes" or "No" shown in the combo box
is the bound column value?

Try this:

If Me![ComboName] = -1 Then
Me![ControlA].SetFocus
Else
Me![ControlB].SetFocus
End If

6) Did you change ControlA and ControlB to the names of your actual
controls?
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Oct 25 '08 #6

P: n/a
I suppose you must have a reason for not using a check box or an option
button, but I can't think what it is

Phil
"Orv" <pc******@hotmale.comwrote in message
news:MK******************************@comcast.com. ..
Ok...finally!

I had the Bound Column set to 1, not 2. This is what worked:

If Me!ComboName = 1 Then
Me!ContolA.SetFocus
Else
Me!ControlB.SetFocus
End If

What I meant by "Yes/No" in a seperate tbl is that I have a tbl named
tblYesNo with pkYN(Autonumber) and fkYN, with 1st row "Yes" and 2nd row
"No". I then place my combo box on form from the field (I need a Yes/No
for) and have it store that value in the field in my main tbl.

Not sure if I explained it correctly.

End Sub
"fredg" <fg******@example.invalidwrote in message
news:pb*****************************@40tude.net...
>On Sat, 25 Oct 2008 07:31:08 -0400, Orv wrote:
>>Thanks for the quick help.
I can't get either of the examples to work.
They both go to the next control.

I tried a simple testDB with only the 3 controls (flat DB and it still
went
to the next control) instead of the "Yes/No" being pulled from seperate
tbl.
I know I'm making this harder than it is.

"fredg" <fg******@example.invalidwrote in message
news:gg*****************************@40tude.net. ..
On Sat, 25 Oct 2008 00:28:33 -0400, Orv wrote:

I have a "Yes/No" combo box (set to required) and I want the focus to
shift
to differnet controls (on the same form) based on the selection of
"Yes"
or
"No". Would this have to be placed on the "Exit" event?
>
I tried Google...and no luck.
I'm sure there's gonna be an "If" statement involved.
>
TIA,
-Orv
Access2003

Code the Combo Box's AfterUpdate event:
If Me![ComboName] = "Yes" Then
Me![ControlA].SetFocus
Else
Me![ControlB].SetFocus
End If
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

1) What do you mean by "Yes/No pulled from a separate table"?
2) What is the EXACT rowsource of the Combo Box?
3) What is the Combo Box Bound Column?
4) What is the Combo Box Column Count?
4) Did you change [ComboName] to the actual name of your combo box?
5) Are you sure the Text value of "Yes" or "No" shown in the combo box
is the bound column value?

Try this:

If Me![ComboName] = -1 Then
Me![ControlA].SetFocus
Else
Me![ControlB].SetFocus
End If

6) Did you change ControlA and ControlB to the names of your actual
controls?
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


Oct 26 '08 #7

P: n/a
Orv
Although you did not ask, I will keep you from wandering.

I used to have a check box, however it wasn't working out to well on the
user end. Funny you should ask though because I had no problems setting the
focus with the checkbox!
-Orv

"Phil Stanton" <ph**@myfamilyname.co.ukwrote in message
news:LP******************************@posted.plusn et...
>I suppose you must have a reason for not using a check box or an option
button, but I can't think what it is

Phil
"Orv" <pc******@hotmale.comwrote in message
news:MK******************************@comcast.com. ..
>Ok...finally!

I had the Bound Column set to 1, not 2. This is what worked:

If Me!ComboName = 1 Then
Me!ContolA.SetFocus
Else
Me!ControlB.SetFocus
End If

What I meant by "Yes/No" in a seperate tbl is that I have a tbl named
tblYesNo with pkYN(Autonumber) and fkYN, with 1st row "Yes" and 2nd row
"No". I then place my combo box on form from the field (I need a Yes/No
for) and have it store that value in the field in my main tbl.

Not sure if I explained it correctly.

End Sub
"fredg" <fg******@example.invalidwrote in message
news:pb*****************************@40tude.net.. .
>>On Sat, 25 Oct 2008 07:31:08 -0400, Orv wrote:

Thanks for the quick help.
I can't get either of the examples to work.
They both go to the next control.

I tried a simple testDB with only the 3 controls (flat DB and it still
went
to the next control) instead of the "Yes/No" being pulled from seperate
tbl.
I know I'm making this harder than it is.

"fredg" <fg******@example.invalidwrote in message
news:gg*****************************@40tude.net ...
On Sat, 25 Oct 2008 00:28:33 -0400, Orv wrote:
>
>I have a "Yes/No" combo box (set to required) and I want the focus to
>shift
>to differnet controls (on the same form) based on the selection of
>"Yes"
>or
>"No". Would this have to be placed on the "Exit" event?
>>
>I tried Google...and no luck.
>I'm sure there's gonna be an "If" statement involved.
>>
>TIA,
>-Orv
>Access2003
>
Code the Combo Box's AfterUpdate event:
If Me![ComboName] = "Yes" Then
Me![ControlA].SetFocus
Else
Me![ControlB].SetFocus
End If
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

1) What do you mean by "Yes/No pulled from a separate table"?
2) What is the EXACT rowsource of the Combo Box?
3) What is the Combo Box Bound Column?
4) What is the Combo Box Column Count?
4) Did you change [ComboName] to the actual name of your combo box?
5) Are you sure the Text value of "Yes" or "No" shown in the combo box
is the bound column value?

Try this:

If Me![ComboName] = -1 Then
Me![ControlA].SetFocus
Else
Me![ControlB].SetFocus
End If

6) Did you change ControlA and ControlB to the names of your actual
controls?
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail



Oct 27 '08 #8

This discussion thread is closed

Replies have been disabled for this discussion.