Help with Select Case/Set Focus/GoToControl

  • Thread starter CurtisK-Houston, TX
  • Start date
C

CurtisK-Houston, TX

I have a combo box in a form that has five variables to select. If they
select "Won" it takes them to a different control near the bottom form, if
"Lost" is selected it takes them to yet another, however, if they select any
of the first three variables prior to "Won" and "Lost" it should simply take
the to the next control in the tab order on the form.

Here is the code I currently have in place:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
DoCmd.GoToControl "Primary Win Reason"
Case Is = Lost
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

All this succeeds in doing is taking the user to the "Primary Win Reason"
control on the form regardless of which of the 5 variables they chose.

I also get similar results with the following code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
Me![Primary Win Reason].SetFocus
Case Is = Lost
Me![Primary Loss Reason].SetFocus
Case Else
Me![Win Probability (%)].SetFocus
End Select

End Sub

Someone please help!

Thanks in advance,
Curtis King-Houston, TX
 
M

Mr. B

Hi, CurtisK.

I have to assume that your combo box only has the text for the available
values. By this I mean that there is no ID number associated with each
selection.

If this is the case then you should try this:

Private Sub Stage_AfterUpdate()
Private Sub Stage_AfterUpdate()
Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub
 
C

CurtisK-Houston, TX

I actually had your version of the code in at one time. All this does is that
it takes them directly to the next tab/control which is the "Win Probability
(%)" field specified in the Case Else statement.

To answer your other question, no I do not have numerical values associated
with any of these 5 variables. I don't know how to do that and did not think
I needed to. Under the 'Data' tab in properties for this Comobo Box I have
the following:

Row Source Type: Value List
Row Source: "New Opportunity Identified";"In Process";"Pending";"Won";"Lost"

If there is an easy way to show me how to assign numerical values to the
variables yet still have them disply in the form as the text labels above
then I'm open to suggestions since I'm kind of stuck at this point.

One last question. Is my syntax correct here. I did not think I would be
using quotation marks for both the names of the variables I'm choosing within
a form control field (i.e. Row Source info listed above for cboStage) and the
name of the form controls such as Primary Win Reason and Primary Loss Reason.

Thanks for your help!

Mr. B said:
Hi, CurtisK.

I have to assume that your combo box only has the text for the available
values. By this I mean that there is no ID number associated with each
selection.

If this is the case then you should try this:

Private Sub Stage_AfterUpdate()
Private Sub Stage_AfterUpdate()
Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

-----
HTH
Mr. B
askdoctoraccess dot com


CurtisK-Houston said:
I have a combo box in a form that has five variables to select. If they
select "Won" it takes them to a different control near the bottom form, if
"Lost" is selected it takes them to yet another, however, if they select any
of the first three variables prior to "Won" and "Lost" it should simply take
the to the next control in the tab order on the form.

Here is the code I currently have in place:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
DoCmd.GoToControl "Primary Win Reason"
Case Is = Lost
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

All this succeeds in doing is taking the user to the "Primary Win Reason"
control on the form regardless of which of the 5 variables they chose.

I also get similar results with the following code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
Me![Primary Win Reason].SetFocus
Case Is = Lost
Me![Primary Loss Reason].SetFocus
Case Else
Me![Win Probability (%)].SetFocus
End Select

End Sub

Someone please help!

Thanks in advance,
Curtis King-Houston, TX
 
M

Mr. B

Curtis,

From you reply I gather that you have one combo box named, "cboStatus" and
three text boxes named as follows: one named: "Primary Win Reason", one
named: "Primary Loss Reason" and one named: "Win Probability (%)".

First I would suggest that you might want to use a more consistant nameing
conventions for your controls. I would suggest naming them like:
"txtPrimaryWinReason", "txtPrimaryLossReason" and "txtWinProbability" (notice
that I did not include the "(%)" as part of the name of the control. There
is a potential for this to create problems if it is in the name of the
control. But all of this has nothing to do with the fact that the code does
not work as you want it to.

If you have the controls named the way you indicate, using the code below
will place the cursor in the text box control per the case statememts for
each option. I have now created and tested it here so I can say that it does
work.

Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select

Give this code a try and post back your results

As for numbers in your combo box, I will be happy to tell you how to do
this, but first let me say that it is not necessary. I was asking so I would
know that you needed quotations aroung the value for each of the Case options.

If you really wanted to have a defined list in your combo box as you
currently have but you also wanted to have a numeric value associated with
each possible value, you would need to have the following properties for your
combo box:

Watch for line wraping in the info below. The Row Source does not have a
second line.
Row Source: 1;"New Opportunity Identified";2;"In
Process";3;"Pending";4;"Won";5;"Lost"
Column Count: 2
Column Widths: 0";2"

The zero as the first value in the column widths is there to cause the
numeric values (the first column of information) to not be displayed. The
second value (2") can be any value you need to display what you are trying to
show in the combo box.

If you implemented all of the changes that I have suggested (changing the
name of the text boxes and adding a numeric value to your combo box then the
code in the after update event of the combo box would look like this:

Select Case cboStage
Case 4 'the "Won" option was selected
DoCmd.GoToControl "txtPrimaryWinReason"
Case 5 'the "Lost" option was selected
DoCmd.GoToControl "txtPrimaryLossReason"
Case Else 'some othere options was selected
DoCmd.GoToControl "txtWinProbability"
End Select

-----
HTH
Mr. B
askdoctoraccess dot com


CurtisK-Houston said:
I actually had your version of the code in at one time. All this does is that
it takes them directly to the next tab/control which is the "Win Probability
(%)" field specified in the Case Else statement.

To answer your other question, no I do not have numerical values associated
with any of these 5 variables. I don't know how to do that and did not think
I needed to. Under the 'Data' tab in properties for this Comobo Box I have
the following:

Row Source Type: Value List
Row Source: "New Opportunity Identified";"In Process";"Pending";"Won";"Lost"

If there is an easy way to show me how to assign numerical values to the
variables yet still have them disply in the form as the text labels above
then I'm open to suggestions since I'm kind of stuck at this point.

One last question. Is my syntax correct here. I did not think I would be
using quotation marks for both the names of the variables I'm choosing within
a form control field (i.e. Row Source info listed above for cboStage) and the
name of the form controls such as Primary Win Reason and Primary Loss Reason.

Thanks for your help!

Mr. B said:
Hi, CurtisK.

I have to assume that your combo box only has the text for the available
values. By this I mean that there is no ID number associated with each
selection.

If this is the case then you should try this:

Private Sub Stage_AfterUpdate()
Private Sub Stage_AfterUpdate()
Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

-----
HTH
Mr. B
askdoctoraccess dot com


CurtisK-Houston said:
I have a combo box in a form that has five variables to select. If they
select "Won" it takes them to a different control near the bottom form, if
"Lost" is selected it takes them to yet another, however, if they select any
of the first three variables prior to "Won" and "Lost" it should simply take
the to the next control in the tab order on the form.

Here is the code I currently have in place:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
DoCmd.GoToControl "Primary Win Reason"
Case Is = Lost
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

All this succeeds in doing is taking the user to the "Primary Win Reason"
control on the form regardless of which of the 5 variables they chose.

I also get similar results with the following code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
Me![Primary Win Reason].SetFocus
Case Is = Lost
Me![Primary Loss Reason].SetFocus
Case Else
Me![Win Probability (%)].SetFocus
End Select

End Sub

Someone please help!

Thanks in advance,
Curtis King-Houston, TX
 
C

CurtisK-Houston, TX

Did not help but keep in mind that Primary Win Reason and Primary Loss Reason
are combo boxes not text boxes. Does that make a difference in the code.

Also when you say change the name does that simply mean a change the name of
the control under properties in design mode of the form. For Example I
currently had the name Primary Win Reason in the form properties for this
combo box and using your example have changed it to txtPrimaryWinReason.
Also do I have to also change the Control Source from the Table as well.

Thanks

Mr. B said:
Curtis,

From you reply I gather that you have one combo box named, "cboStatus" and
three text boxes named as follows: one named: "Primary Win Reason", one
named: "Primary Loss Reason" and one named: "Win Probability (%)".

First I would suggest that you might want to use a more consistant nameing
conventions for your controls. I would suggest naming them like:
"txtPrimaryWinReason", "txtPrimaryLossReason" and "txtWinProbability" (notice
that I did not include the "(%)" as part of the name of the control. There
is a potential for this to create problems if it is in the name of the
control. But all of this has nothing to do with the fact that the code does
not work as you want it to.

If you have the controls named the way you indicate, using the code below
will place the cursor in the text box control per the case statememts for
each option. I have now created and tested it here so I can say that it does
work.

Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select

Give this code a try and post back your results

As for numbers in your combo box, I will be happy to tell you how to do
this, but first let me say that it is not necessary. I was asking so I would
know that you needed quotations aroung the value for each of the Case options.

If you really wanted to have a defined list in your combo box as you
currently have but you also wanted to have a numeric value associated with
each possible value, you would need to have the following properties for your
combo box:

Watch for line wraping in the info below. The Row Source does not have a
second line.
Row Source: 1;"New Opportunity Identified";2;"In
Process";3;"Pending";4;"Won";5;"Lost"
Column Count: 2
Column Widths: 0";2"

The zero as the first value in the column widths is there to cause the
numeric values (the first column of information) to not be displayed. The
second value (2") can be any value you need to display what you are trying to
show in the combo box.

If you implemented all of the changes that I have suggested (changing the
name of the text boxes and adding a numeric value to your combo box then the
code in the after update event of the combo box would look like this:

Select Case cboStage
Case 4 'the "Won" option was selected
DoCmd.GoToControl "txtPrimaryWinReason"
Case 5 'the "Lost" option was selected
DoCmd.GoToControl "txtPrimaryLossReason"
Case Else 'some othere options was selected
DoCmd.GoToControl "txtWinProbability"
End Select

-----
HTH
Mr. B
askdoctoraccess dot com


CurtisK-Houston said:
I actually had your version of the code in at one time. All this does is that
it takes them directly to the next tab/control which is the "Win Probability
(%)" field specified in the Case Else statement.

To answer your other question, no I do not have numerical values associated
with any of these 5 variables. I don't know how to do that and did not think
I needed to. Under the 'Data' tab in properties for this Comobo Box I have
the following:

Row Source Type: Value List
Row Source: "New Opportunity Identified";"In Process";"Pending";"Won";"Lost"

If there is an easy way to show me how to assign numerical values to the
variables yet still have them disply in the form as the text labels above
then I'm open to suggestions since I'm kind of stuck at this point.

One last question. Is my syntax correct here. I did not think I would be
using quotation marks for both the names of the variables I'm choosing within
a form control field (i.e. Row Source info listed above for cboStage) and the
name of the form controls such as Primary Win Reason and Primary Loss Reason.

Thanks for your help!

Mr. B said:
Hi, CurtisK.

I have to assume that your combo box only has the text for the available
values. By this I mean that there is no ID number associated with each
selection.

If this is the case then you should try this:

Private Sub Stage_AfterUpdate()
Private Sub Stage_AfterUpdate()
Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

-----
HTH
Mr. B
askdoctoraccess dot com


:

I have a combo box in a form that has five variables to select. If they
select "Won" it takes them to a different control near the bottom form, if
"Lost" is selected it takes them to yet another, however, if they select any
of the first three variables prior to "Won" and "Lost" it should simply take
the to the next control in the tab order on the form.

Here is the code I currently have in place:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
DoCmd.GoToControl "Primary Win Reason"
Case Is = Lost
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

All this succeeds in doing is taking the user to the "Primary Win Reason"
control on the form regardless of which of the 5 variables they chose.

I also get similar results with the following code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
Me![Primary Win Reason].SetFocus
Case Is = Lost
Me![Primary Loss Reason].SetFocus
Case Else
Me![Win Probability (%)].SetFocus
End Select

End Sub

Someone please help!

Thanks in advance,
Curtis King-Houston, TX
 
M

Mr. B

Curtis,

I think I am getting a little confused here.

The fact that a control is a text box or a combo box will not make any
difference in trying to set the focus to a control.

The "name" for your controls is managed using the "Name" property. This
property is found in the Properties dialog box on the "Other" tab.

As I tried to say in my previous post, in this case, the name you have on
the control will not make a difference in making the Case statement move the
focus to a specific control based on the selection made in the "cboStage"
combo box.

The control soruce for a control has nothing to do with the name of the
control. That statement may not be true if you are referenceing the control
in the criteria of a query that is serving as the record source for a combo
box. In this case, the name of the control will make a difference.

Let's get your code working before we worry about naming conventions.

-----
HTH
Mr. B
askdoctoraccess dot com


CurtisK-Houston said:
Did not help but keep in mind that Primary Win Reason and Primary Loss Reason
are combo boxes not text boxes. Does that make a difference in the code.

Also when you say change the name does that simply mean a change the name of
the control under properties in design mode of the form. For Example I
currently had the name Primary Win Reason in the form properties for this
combo box and using your example have changed it to txtPrimaryWinReason.
Also do I have to also change the Control Source from the Table as well.

Thanks

Mr. B said:
Curtis,

From you reply I gather that you have one combo box named, "cboStatus" and
three text boxes named as follows: one named: "Primary Win Reason", one
named: "Primary Loss Reason" and one named: "Win Probability (%)".

First I would suggest that you might want to use a more consistant nameing
conventions for your controls. I would suggest naming them like:
"txtPrimaryWinReason", "txtPrimaryLossReason" and "txtWinProbability" (notice
that I did not include the "(%)" as part of the name of the control. There
is a potential for this to create problems if it is in the name of the
control. But all of this has nothing to do with the fact that the code does
not work as you want it to.

If you have the controls named the way you indicate, using the code below
will place the cursor in the text box control per the case statememts for
each option. I have now created and tested it here so I can say that it does
work.

Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select

Give this code a try and post back your results

As for numbers in your combo box, I will be happy to tell you how to do
this, but first let me say that it is not necessary. I was asking so I would
know that you needed quotations aroung the value for each of the Case options.

If you really wanted to have a defined list in your combo box as you
currently have but you also wanted to have a numeric value associated with
each possible value, you would need to have the following properties for your
combo box:

Watch for line wraping in the info below. The Row Source does not have a
second line.
Row Source: 1;"New Opportunity Identified";2;"In
Process";3;"Pending";4;"Won";5;"Lost"
Column Count: 2
Column Widths: 0";2"

The zero as the first value in the column widths is there to cause the
numeric values (the first column of information) to not be displayed. The
second value (2") can be any value you need to display what you are trying to
show in the combo box.

If you implemented all of the changes that I have suggested (changing the
name of the text boxes and adding a numeric value to your combo box then the
code in the after update event of the combo box would look like this:

Select Case cboStage
Case 4 'the "Won" option was selected
DoCmd.GoToControl "txtPrimaryWinReason"
Case 5 'the "Lost" option was selected
DoCmd.GoToControl "txtPrimaryLossReason"
Case Else 'some othere options was selected
DoCmd.GoToControl "txtWinProbability"
End Select

-----
HTH
Mr. B
askdoctoraccess dot com


CurtisK-Houston said:
I actually had your version of the code in at one time. All this does is that
it takes them directly to the next tab/control which is the "Win Probability
(%)" field specified in the Case Else statement.

To answer your other question, no I do not have numerical values associated
with any of these 5 variables. I don't know how to do that and did not think
I needed to. Under the 'Data' tab in properties for this Comobo Box I have
the following:

Row Source Type: Value List
Row Source: "New Opportunity Identified";"In Process";"Pending";"Won";"Lost"

If there is an easy way to show me how to assign numerical values to the
variables yet still have them disply in the form as the text labels above
then I'm open to suggestions since I'm kind of stuck at this point.

One last question. Is my syntax correct here. I did not think I would be
using quotation marks for both the names of the variables I'm choosing within
a form control field (i.e. Row Source info listed above for cboStage) and the
name of the form controls such as Primary Win Reason and Primary Loss Reason.

Thanks for your help!

:

Hi, CurtisK.

I have to assume that your combo box only has the text for the available
values. By this I mean that there is no ID number associated with each
selection.

If this is the case then you should try this:

Private Sub Stage_AfterUpdate()
Private Sub Stage_AfterUpdate()
Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

-----
HTH
Mr. B
askdoctoraccess dot com


:

I have a combo box in a form that has five variables to select. If they
select "Won" it takes them to a different control near the bottom form, if
"Lost" is selected it takes them to yet another, however, if they select any
of the first three variables prior to "Won" and "Lost" it should simply take
the to the next control in the tab order on the form.

Here is the code I currently have in place:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
DoCmd.GoToControl "Primary Win Reason"
Case Is = Lost
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

All this succeeds in doing is taking the user to the "Primary Win Reason"
control on the form regardless of which of the 5 variables they chose.

I also get similar results with the following code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
Me![Primary Win Reason].SetFocus
Case Is = Lost
Me![Primary Loss Reason].SetFocus
Case Else
Me![Win Probability (%)].SetFocus
End Select

End Sub

Someone please help!

Thanks in advance,
Curtis King-Houston, TX
 
C

CurtisK-Houston, TX

Well after your original option did not work I assigned the values to each of
the variables by cutting and pasting the information as you typed it in your
previous response under the Row Source field and also made the two changes
under both Column Count and Width under properties for the Stage combo box.

This is what I currently have in as my code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case 4 'the "Won" option was selected
DoCmd.GoToControl "cboPrimaryWinReason"
Case 5 'the "Lost" option was selected
DoCmd.GoToControl "cboPrimaryLossReason"
Case Else 'some othere options was selected
DoCmd.GoToControl "txtWinProbability"
End Select
End Sub

I also have renamed all three controls to match the expression above. The
only difference I believe here is that I put cbo instead of txt as the prefix
in front of both Primary Win Reason and Primary Loss Reason which is why I
asked my question because all this continues to do is take the user to the
txtWinProbability field regardless of which of the 5 are chosen.

I sincerely appreciate your time in working with me on this.

Best Regards,
Curtis King-Houston, TX

Mr. B said:
Curtis,

I think I am getting a little confused here.

The fact that a control is a text box or a combo box will not make any
difference in trying to set the focus to a control.

The "name" for your controls is managed using the "Name" property. This
property is found in the Properties dialog box on the "Other" tab.

As I tried to say in my previous post, in this case, the name you have on
the control will not make a difference in making the Case statement move the
focus to a specific control based on the selection made in the "cboStage"
combo box.

The control soruce for a control has nothing to do with the name of the
control. That statement may not be true if you are referenceing the control
in the criteria of a query that is serving as the record source for a combo
box. In this case, the name of the control will make a difference.

Let's get your code working before we worry about naming conventions.

-----
HTH
Mr. B
askdoctoraccess dot com


CurtisK-Houston said:
Did not help but keep in mind that Primary Win Reason and Primary Loss Reason
are combo boxes not text boxes. Does that make a difference in the code.

Also when you say change the name does that simply mean a change the name of
the control under properties in design mode of the form. For Example I
currently had the name Primary Win Reason in the form properties for this
combo box and using your example have changed it to txtPrimaryWinReason.
Also do I have to also change the Control Source from the Table as well.

Thanks

Mr. B said:
Curtis,

From you reply I gather that you have one combo box named, "cboStatus" and
three text boxes named as follows: one named: "Primary Win Reason", one
named: "Primary Loss Reason" and one named: "Win Probability (%)".

First I would suggest that you might want to use a more consistant nameing
conventions for your controls. I would suggest naming them like:
"txtPrimaryWinReason", "txtPrimaryLossReason" and "txtWinProbability" (notice
that I did not include the "(%)" as part of the name of the control. There
is a potential for this to create problems if it is in the name of the
control. But all of this has nothing to do with the fact that the code does
not work as you want it to.

If you have the controls named the way you indicate, using the code below
will place the cursor in the text box control per the case statememts for
each option. I have now created and tested it here so I can say that it does
work.

Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select

Give this code a try and post back your results

As for numbers in your combo box, I will be happy to tell you how to do
this, but first let me say that it is not necessary. I was asking so I would
know that you needed quotations aroung the value for each of the Case options.

If you really wanted to have a defined list in your combo box as you
currently have but you also wanted to have a numeric value associated with
each possible value, you would need to have the following properties for your
combo box:

Watch for line wraping in the info below. The Row Source does not have a
second line.
Row Source: 1;"New Opportunity Identified";2;"In
Process";3;"Pending";4;"Won";5;"Lost"
Column Count: 2
Column Widths: 0";2"

The zero as the first value in the column widths is there to cause the
numeric values (the first column of information) to not be displayed. The
second value (2") can be any value you need to display what you are trying to
show in the combo box.

If you implemented all of the changes that I have suggested (changing the
name of the text boxes and adding a numeric value to your combo box then the
code in the after update event of the combo box would look like this:

Select Case cboStage
Case 4 'the "Won" option was selected
DoCmd.GoToControl "txtPrimaryWinReason"
Case 5 'the "Lost" option was selected
DoCmd.GoToControl "txtPrimaryLossReason"
Case Else 'some othere options was selected
DoCmd.GoToControl "txtWinProbability"
End Select

-----
HTH
Mr. B
askdoctoraccess dot com


:

I actually had your version of the code in at one time. All this does is that
it takes them directly to the next tab/control which is the "Win Probability
(%)" field specified in the Case Else statement.

To answer your other question, no I do not have numerical values associated
with any of these 5 variables. I don't know how to do that and did not think
I needed to. Under the 'Data' tab in properties for this Comobo Box I have
the following:

Row Source Type: Value List
Row Source: "New Opportunity Identified";"In Process";"Pending";"Won";"Lost"

If there is an easy way to show me how to assign numerical values to the
variables yet still have them disply in the form as the text labels above
then I'm open to suggestions since I'm kind of stuck at this point.

One last question. Is my syntax correct here. I did not think I would be
using quotation marks for both the names of the variables I'm choosing within
a form control field (i.e. Row Source info listed above for cboStage) and the
name of the form controls such as Primary Win Reason and Primary Loss Reason.

Thanks for your help!

:

Hi, CurtisK.

I have to assume that your combo box only has the text for the available
values. By this I mean that there is no ID number associated with each
selection.

If this is the case then you should try this:

Private Sub Stage_AfterUpdate()
Private Sub Stage_AfterUpdate()
Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

-----
HTH
Mr. B
askdoctoraccess dot com


:

I have a combo box in a form that has five variables to select. If they
select "Won" it takes them to a different control near the bottom form, if
"Lost" is selected it takes them to yet another, however, if they select any
of the first three variables prior to "Won" and "Lost" it should simply take
the to the next control in the tab order on the form.

Here is the code I currently have in place:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
DoCmd.GoToControl "Primary Win Reason"
Case Is = Lost
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

All this succeeds in doing is taking the user to the "Primary Win Reason"
control on the form regardless of which of the 5 variables they chose.

I also get similar results with the following code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
Me![Primary Win Reason].SetFocus
Case Is = Lost
Me![Primary Loss Reason].SetFocus
Case Else
Me![Win Probability (%)].SetFocus
End Select

End Sub

Someone please help!

Thanks in advance,
Curtis King-Houston, TX
 
M

Mr. B

Did you also make the changes to the Column Count property and the Column
Width property of the first combo box?

You need to go to the code window and add a breakpoint at the start of the
Case statement. With the code for the combo box visible, place your cursor in
the line: "Select Case cboState" and locate the icon on the tool bar that
looks like a Hane and click it to place the breakpoint. Then run your form
and select an option from the combo box. You should be taken to the code
window where you should be able to step through the code to see which value
is being returned by the code from the cboStage combo box. You should be
able to place your cursor over the "cboState" part of the statement and a
tooltip would appear showing the value that is held in that object. Then you
can use the "Step Into" button to cause the code to execute one line at a
time and you will be able to see where it goes in the Case Statement and
which lines get executed.

Post back a let me know what you see as a result.

-----
HTH
Mr. B
askdoctoraccess dot com


CurtisK-Houston said:
Well after your original option did not work I assigned the values to each of
the variables by cutting and pasting the information as you typed it in your
previous response under the Row Source field and also made the two changes
under both Column Count and Width under properties for the Stage combo box.

This is what I currently have in as my code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case 4 'the "Won" option was selected
DoCmd.GoToControl "cboPrimaryWinReason"
Case 5 'the "Lost" option was selected
DoCmd.GoToControl "cboPrimaryLossReason"
Case Else 'some othere options was selected
DoCmd.GoToControl "txtWinProbability"
End Select
End Sub

I also have renamed all three controls to match the expression above. The
only difference I believe here is that I put cbo instead of txt as the prefix
in front of both Primary Win Reason and Primary Loss Reason which is why I
asked my question because all this continues to do is take the user to the
txtWinProbability field regardless of which of the 5 are chosen.

I sincerely appreciate your time in working with me on this.

Best Regards,
Curtis King-Houston, TX

Mr. B said:
Curtis,

I think I am getting a little confused here.

The fact that a control is a text box or a combo box will not make any
difference in trying to set the focus to a control.

The "name" for your controls is managed using the "Name" property. This
property is found in the Properties dialog box on the "Other" tab.

As I tried to say in my previous post, in this case, the name you have on
the control will not make a difference in making the Case statement move the
focus to a specific control based on the selection made in the "cboStage"
combo box.

The control soruce for a control has nothing to do with the name of the
control. That statement may not be true if you are referenceing the control
in the criteria of a query that is serving as the record source for a combo
box. In this case, the name of the control will make a difference.

Let's get your code working before we worry about naming conventions.

-----
HTH
Mr. B
askdoctoraccess dot com


CurtisK-Houston said:
Did not help but keep in mind that Primary Win Reason and Primary Loss Reason
are combo boxes not text boxes. Does that make a difference in the code.

Also when you say change the name does that simply mean a change the name of
the control under properties in design mode of the form. For Example I
currently had the name Primary Win Reason in the form properties for this
combo box and using your example have changed it to txtPrimaryWinReason.
Also do I have to also change the Control Source from the Table as well.

Thanks

:

Curtis,

From you reply I gather that you have one combo box named, "cboStatus" and
three text boxes named as follows: one named: "Primary Win Reason", one
named: "Primary Loss Reason" and one named: "Win Probability (%)".

First I would suggest that you might want to use a more consistant nameing
conventions for your controls. I would suggest naming them like:
"txtPrimaryWinReason", "txtPrimaryLossReason" and "txtWinProbability" (notice
that I did not include the "(%)" as part of the name of the control. There
is a potential for this to create problems if it is in the name of the
control. But all of this has nothing to do with the fact that the code does
not work as you want it to.

If you have the controls named the way you indicate, using the code below
will place the cursor in the text box control per the case statememts for
each option. I have now created and tested it here so I can say that it does
work.

Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select

Give this code a try and post back your results

As for numbers in your combo box, I will be happy to tell you how to do
this, but first let me say that it is not necessary. I was asking so I would
know that you needed quotations aroung the value for each of the Case options.

If you really wanted to have a defined list in your combo box as you
currently have but you also wanted to have a numeric value associated with
each possible value, you would need to have the following properties for your
combo box:

Watch for line wraping in the info below. The Row Source does not have a
second line.
Row Source: 1;"New Opportunity Identified";2;"In
Process";3;"Pending";4;"Won";5;"Lost"
Column Count: 2
Column Widths: 0";2"

The zero as the first value in the column widths is there to cause the
numeric values (the first column of information) to not be displayed. The
second value (2") can be any value you need to display what you are trying to
show in the combo box.

If you implemented all of the changes that I have suggested (changing the
name of the text boxes and adding a numeric value to your combo box then the
code in the after update event of the combo box would look like this:

Select Case cboStage
Case 4 'the "Won" option was selected
DoCmd.GoToControl "txtPrimaryWinReason"
Case 5 'the "Lost" option was selected
DoCmd.GoToControl "txtPrimaryLossReason"
Case Else 'some othere options was selected
DoCmd.GoToControl "txtWinProbability"
End Select

-----
HTH
Mr. B
askdoctoraccess dot com


:

I actually had your version of the code in at one time. All this does is that
it takes them directly to the next tab/control which is the "Win Probability
(%)" field specified in the Case Else statement.

To answer your other question, no I do not have numerical values associated
with any of these 5 variables. I don't know how to do that and did not think
I needed to. Under the 'Data' tab in properties for this Comobo Box I have
the following:

Row Source Type: Value List
Row Source: "New Opportunity Identified";"In Process";"Pending";"Won";"Lost"

If there is an easy way to show me how to assign numerical values to the
variables yet still have them disply in the form as the text labels above
then I'm open to suggestions since I'm kind of stuck at this point.

One last question. Is my syntax correct here. I did not think I would be
using quotation marks for both the names of the variables I'm choosing within
a form control field (i.e. Row Source info listed above for cboStage) and the
name of the form controls such as Primary Win Reason and Primary Loss Reason.

Thanks for your help!

:

Hi, CurtisK.

I have to assume that your combo box only has the text for the available
values. By this I mean that there is no ID number associated with each
selection.

If this is the case then you should try this:

Private Sub Stage_AfterUpdate()
Private Sub Stage_AfterUpdate()
Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

-----
HTH
Mr. B
askdoctoraccess dot com


:

I have a combo box in a form that has five variables to select. If they
select "Won" it takes them to a different control near the bottom form, if
"Lost" is selected it takes them to yet another, however, if they select any
of the first three variables prior to "Won" and "Lost" it should simply take
the to the next control in the tab order on the form.

Here is the code I currently have in place:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
DoCmd.GoToControl "Primary Win Reason"
Case Is = Lost
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

All this succeeds in doing is taking the user to the "Primary Win Reason"
control on the form regardless of which of the 5 variables they chose.

I also get similar results with the following code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
Me![Primary Win Reason].SetFocus
Case Is = Lost
Me![Primary Loss Reason].SetFocus
Case Else
Me![Win Probability (%)].SetFocus
End Select

End Sub

Someone please help!

Thanks in advance,
Curtis King-Houston, TX
 
C

CurtisK-Houston, TX

You wrote:

Did you also make the changes to the Column Count property and the Column
Width property of the first combo box?

My Answer: Yes I did. I thought I indicated that in my previous response to
you but I must not have communicated it properly.

You wrote:

You need to go to the code window and add a breakpoint at the start of the
Case statement. With the code for the combo box visible, place your cursor in
the line: "Select Case cboState" and locate the icon on the tool bar that
looks like a Hane and click it to place the breakpoint.

My Answer: Now I guess I am a little confused. I don't know what a 'Hane' is
to even know what toolbar button to press.

I would be more than willing to send you the actual dbase file if you would
like to see it because it seems like I'm really close yet I must not be doing
a good job of communicating the problem to you in order to get the solution.

Again I sincerely appreciate your help.

CurtisK-Houston, TX

Mr. B said:
Did you also make the changes to the Column Count property and the Column
Width property of the first combo box?

You need to go to the code window and add a breakpoint at the start of the
Case statement. With the code for the combo box visible, place your cursor in
the line: "Select Case cboState" and locate the icon on the tool bar that
looks like a Hane and click it to place the breakpoint. Then run your form
and select an option from the combo box. You should be taken to the code
window where you should be able to step through the code to see which value
is being returned by the code from the cboStage combo box. You should be
able to place your cursor over the "cboState" part of the statement and a
tooltip would appear showing the value that is held in that object. Then you
can use the "Step Into" button to cause the code to execute one line at a
time and you will be able to see where it goes in the Case Statement and
which lines get executed.

Post back a let me know what you see as a result.

-----
HTH
Mr. B
askdoctoraccess dot com


CurtisK-Houston said:
Well after your original option did not work I assigned the values to each of
the variables by cutting and pasting the information as you typed it in your
previous response under the Row Source field and also made the two changes
under both Column Count and Width under properties for the Stage combo box.

This is what I currently have in as my code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case 4 'the "Won" option was selected
DoCmd.GoToControl "cboPrimaryWinReason"
Case 5 'the "Lost" option was selected
DoCmd.GoToControl "cboPrimaryLossReason"
Case Else 'some othere options was selected
DoCmd.GoToControl "txtWinProbability"
End Select
End Sub

I also have renamed all three controls to match the expression above. The
only difference I believe here is that I put cbo instead of txt as the prefix
in front of both Primary Win Reason and Primary Loss Reason which is why I
asked my question because all this continues to do is take the user to the
txtWinProbability field regardless of which of the 5 are chosen.

I sincerely appreciate your time in working with me on this.

Best Regards,
Curtis King-Houston, TX

Mr. B said:
Curtis,

I think I am getting a little confused here.

The fact that a control is a text box or a combo box will not make any
difference in trying to set the focus to a control.

The "name" for your controls is managed using the "Name" property. This
property is found in the Properties dialog box on the "Other" tab.

As I tried to say in my previous post, in this case, the name you have on
the control will not make a difference in making the Case statement move the
focus to a specific control based on the selection made in the "cboStage"
combo box.

The control soruce for a control has nothing to do with the name of the
control. That statement may not be true if you are referenceing the control
in the criteria of a query that is serving as the record source for a combo
box. In this case, the name of the control will make a difference.

Let's get your code working before we worry about naming conventions.

-----
HTH
Mr. B
askdoctoraccess dot com


:

Did not help but keep in mind that Primary Win Reason and Primary Loss Reason
are combo boxes not text boxes. Does that make a difference in the code.

Also when you say change the name does that simply mean a change the name of
the control under properties in design mode of the form. For Example I
currently had the name Primary Win Reason in the form properties for this
combo box and using your example have changed it to txtPrimaryWinReason.
Also do I have to also change the Control Source from the Table as well.

Thanks

:

Curtis,

From you reply I gather that you have one combo box named, "cboStatus" and
three text boxes named as follows: one named: "Primary Win Reason", one
named: "Primary Loss Reason" and one named: "Win Probability (%)".

First I would suggest that you might want to use a more consistant nameing
conventions for your controls. I would suggest naming them like:
"txtPrimaryWinReason", "txtPrimaryLossReason" and "txtWinProbability" (notice
that I did not include the "(%)" as part of the name of the control. There
is a potential for this to create problems if it is in the name of the
control. But all of this has nothing to do with the fact that the code does
not work as you want it to.

If you have the controls named the way you indicate, using the code below
will place the cursor in the text box control per the case statememts for
each option. I have now created and tested it here so I can say that it does
work.

Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select

Give this code a try and post back your results

As for numbers in your combo box, I will be happy to tell you how to do
this, but first let me say that it is not necessary. I was asking so I would
know that you needed quotations aroung the value for each of the Case options.

If you really wanted to have a defined list in your combo box as you
currently have but you also wanted to have a numeric value associated with
each possible value, you would need to have the following properties for your
combo box:

Watch for line wraping in the info below. The Row Source does not have a
second line.
Row Source: 1;"New Opportunity Identified";2;"In
Process";3;"Pending";4;"Won";5;"Lost"
Column Count: 2
Column Widths: 0";2"

The zero as the first value in the column widths is there to cause the
numeric values (the first column of information) to not be displayed. The
second value (2") can be any value you need to display what you are trying to
show in the combo box.

If you implemented all of the changes that I have suggested (changing the
name of the text boxes and adding a numeric value to your combo box then the
code in the after update event of the combo box would look like this:

Select Case cboStage
Case 4 'the "Won" option was selected
DoCmd.GoToControl "txtPrimaryWinReason"
Case 5 'the "Lost" option was selected
DoCmd.GoToControl "txtPrimaryLossReason"
Case Else 'some othere options was selected
DoCmd.GoToControl "txtWinProbability"
End Select

-----
HTH
Mr. B
askdoctoraccess dot com


:

I actually had your version of the code in at one time. All this does is that
it takes them directly to the next tab/control which is the "Win Probability
(%)" field specified in the Case Else statement.

To answer your other question, no I do not have numerical values associated
with any of these 5 variables. I don't know how to do that and did not think
I needed to. Under the 'Data' tab in properties for this Comobo Box I have
the following:

Row Source Type: Value List
Row Source: "New Opportunity Identified";"In Process";"Pending";"Won";"Lost"

If there is an easy way to show me how to assign numerical values to the
variables yet still have them disply in the form as the text labels above
then I'm open to suggestions since I'm kind of stuck at this point.

One last question. Is my syntax correct here. I did not think I would be
using quotation marks for both the names of the variables I'm choosing within
a form control field (i.e. Row Source info listed above for cboStage) and the
name of the form controls such as Primary Win Reason and Primary Loss Reason.

Thanks for your help!

:

Hi, CurtisK.

I have to assume that your combo box only has the text for the available
values. By this I mean that there is no ID number associated with each
selection.

If this is the case then you should try this:

Private Sub Stage_AfterUpdate()
Private Sub Stage_AfterUpdate()
Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

-----
HTH
Mr. B
askdoctoraccess dot com


:

I have a combo box in a form that has five variables to select. If they
select "Won" it takes them to a different control near the bottom form, if
"Lost" is selected it takes them to yet another, however, if they select any
of the first three variables prior to "Won" and "Lost" it should simply take
the to the next control in the tab order on the form.

Here is the code I currently have in place:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
DoCmd.GoToControl "Primary Win Reason"
Case Is = Lost
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

All this succeeds in doing is taking the user to the "Primary Win Reason"
control on the form regardless of which of the 5 variables they chose.

I also get similar results with the following code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
Me![Primary Win Reason].SetFocus
Case Is = Lost
Me![Primary Loss Reason].SetFocus
Case Else
Me![Win Probability (%)].SetFocus
End Select

End Sub

Someone please help!

Thanks in advance,
Curtis King-Houston, TX
 
M

Mr. B

Curtis,

I like to keep answers in the newsgroup where all can benifit from the
solutions, however, I do agree with you that we are evidently not making the
progress that I would like. So, with that said, if you would like, you can
go to my website (askdoctoraccess dot com, just convdert the "dot" to a ".")
and there you will find a link to send me an email. You can attach the
database file and I will look at it.

Then we can again post solutions to the group.

-----
HTH
Mr. B
askdoctoraccess dot com


CurtisK-Houston said:
You wrote:

Did you also make the changes to the Column Count property and the Column
Width property of the first combo box?

My Answer: Yes I did. I thought I indicated that in my previous response to
you but I must not have communicated it properly.

You wrote:

You need to go to the code window and add a breakpoint at the start of the
Case statement. With the code for the combo box visible, place your cursor in
the line: "Select Case cboState" and locate the icon on the tool bar that
looks like a Hane and click it to place the breakpoint.

My Answer: Now I guess I am a little confused. I don't know what a 'Hane' is
to even know what toolbar button to press.

I would be more than willing to send you the actual dbase file if you would
like to see it because it seems like I'm really close yet I must not be doing
a good job of communicating the problem to you in order to get the solution.

Again I sincerely appreciate your help.

CurtisK-Houston, TX

Mr. B said:
Did you also make the changes to the Column Count property and the Column
Width property of the first combo box?

You need to go to the code window and add a breakpoint at the start of the
Case statement. With the code for the combo box visible, place your cursor in
the line: "Select Case cboState" and locate the icon on the tool bar that
looks like a Hane and click it to place the breakpoint. Then run your form
and select an option from the combo box. You should be taken to the code
window where you should be able to step through the code to see which value
is being returned by the code from the cboStage combo box. You should be
able to place your cursor over the "cboState" part of the statement and a
tooltip would appear showing the value that is held in that object. Then you
can use the "Step Into" button to cause the code to execute one line at a
time and you will be able to see where it goes in the Case Statement and
which lines get executed.

Post back a let me know what you see as a result.

-----
HTH
Mr. B
askdoctoraccess dot com


CurtisK-Houston said:
Well after your original option did not work I assigned the values to each of
the variables by cutting and pasting the information as you typed it in your
previous response under the Row Source field and also made the two changes
under both Column Count and Width under properties for the Stage combo box.

This is what I currently have in as my code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case 4 'the "Won" option was selected
DoCmd.GoToControl "cboPrimaryWinReason"
Case 5 'the "Lost" option was selected
DoCmd.GoToControl "cboPrimaryLossReason"
Case Else 'some othere options was selected
DoCmd.GoToControl "txtWinProbability"
End Select
End Sub

I also have renamed all three controls to match the expression above. The
only difference I believe here is that I put cbo instead of txt as the prefix
in front of both Primary Win Reason and Primary Loss Reason which is why I
asked my question because all this continues to do is take the user to the
txtWinProbability field regardless of which of the 5 are chosen.

I sincerely appreciate your time in working with me on this.

Best Regards,
Curtis King-Houston, TX

:

Curtis,

I think I am getting a little confused here.

The fact that a control is a text box or a combo box will not make any
difference in trying to set the focus to a control.

The "name" for your controls is managed using the "Name" property. This
property is found in the Properties dialog box on the "Other" tab.

As I tried to say in my previous post, in this case, the name you have on
the control will not make a difference in making the Case statement move the
focus to a specific control based on the selection made in the "cboStage"
combo box.

The control soruce for a control has nothing to do with the name of the
control. That statement may not be true if you are referenceing the control
in the criteria of a query that is serving as the record source for a combo
box. In this case, the name of the control will make a difference.

Let's get your code working before we worry about naming conventions.

-----
HTH
Mr. B
askdoctoraccess dot com


:

Did not help but keep in mind that Primary Win Reason and Primary Loss Reason
are combo boxes not text boxes. Does that make a difference in the code.

Also when you say change the name does that simply mean a change the name of
the control under properties in design mode of the form. For Example I
currently had the name Primary Win Reason in the form properties for this
combo box and using your example have changed it to txtPrimaryWinReason.
Also do I have to also change the Control Source from the Table as well.

Thanks

:

Curtis,

From you reply I gather that you have one combo box named, "cboStatus" and
three text boxes named as follows: one named: "Primary Win Reason", one
named: "Primary Loss Reason" and one named: "Win Probability (%)".

First I would suggest that you might want to use a more consistant nameing
conventions for your controls. I would suggest naming them like:
"txtPrimaryWinReason", "txtPrimaryLossReason" and "txtWinProbability" (notice
that I did not include the "(%)" as part of the name of the control. There
is a potential for this to create problems if it is in the name of the
control. But all of this has nothing to do with the fact that the code does
not work as you want it to.

If you have the controls named the way you indicate, using the code below
will place the cursor in the text box control per the case statememts for
each option. I have now created and tested it here so I can say that it does
work.

Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select

Give this code a try and post back your results

As for numbers in your combo box, I will be happy to tell you how to do
this, but first let me say that it is not necessary. I was asking so I would
know that you needed quotations aroung the value for each of the Case options.

If you really wanted to have a defined list in your combo box as you
currently have but you also wanted to have a numeric value associated with
each possible value, you would need to have the following properties for your
combo box:

Watch for line wraping in the info below. The Row Source does not have a
second line.
Row Source: 1;"New Opportunity Identified";2;"In
Process";3;"Pending";4;"Won";5;"Lost"
Column Count: 2
Column Widths: 0";2"

The zero as the first value in the column widths is there to cause the
numeric values (the first column of information) to not be displayed. The
second value (2") can be any value you need to display what you are trying to
show in the combo box.

If you implemented all of the changes that I have suggested (changing the
name of the text boxes and adding a numeric value to your combo box then the
code in the after update event of the combo box would look like this:

Select Case cboStage
Case 4 'the "Won" option was selected
DoCmd.GoToControl "txtPrimaryWinReason"
Case 5 'the "Lost" option was selected
DoCmd.GoToControl "txtPrimaryLossReason"
Case Else 'some othere options was selected
DoCmd.GoToControl "txtWinProbability"
End Select

-----
HTH
Mr. B
askdoctoraccess dot com


:

I actually had your version of the code in at one time. All this does is that
it takes them directly to the next tab/control which is the "Win Probability
(%)" field specified in the Case Else statement.

To answer your other question, no I do not have numerical values associated
with any of these 5 variables. I don't know how to do that and did not think
I needed to. Under the 'Data' tab in properties for this Comobo Box I have
the following:

Row Source Type: Value List
Row Source: "New Opportunity Identified";"In Process";"Pending";"Won";"Lost"

If there is an easy way to show me how to assign numerical values to the
variables yet still have them disply in the form as the text labels above
then I'm open to suggestions since I'm kind of stuck at this point.

One last question. Is my syntax correct here. I did not think I would be
using quotation marks for both the names of the variables I'm choosing within
a form control field (i.e. Row Source info listed above for cboStage) and the
name of the form controls such as Primary Win Reason and Primary Loss Reason.

Thanks for your help!

:

Hi, CurtisK.

I have to assume that your combo box only has the text for the available
values. By this I mean that there is no ID number associated with each
selection.

If this is the case then you should try this:

Private Sub Stage_AfterUpdate()
Private Sub Stage_AfterUpdate()
Select Case cboStage
Case "Won"
DoCmd.GoToControl "Primary Win Reason"
Case "Lost"
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

-----
HTH
Mr. B
askdoctoraccess dot com


:

I have a combo box in a form that has five variables to select. If they
select "Won" it takes them to a different control near the bottom form, if
"Lost" is selected it takes them to yet another, however, if they select any
of the first three variables prior to "Won" and "Lost" it should simply take
the to the next control in the tab order on the form.

Here is the code I currently have in place:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
DoCmd.GoToControl "Primary Win Reason"
Case Is = Lost
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

All this succeeds in doing is taking the user to the "Primary Win Reason"
control on the form regardless of which of the 5 variables they chose.

I also get similar results with the following code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
Me![Primary Win Reason].SetFocus
Case Is = Lost
Me![Primary Loss Reason].SetFocus
Case Else
Me![Win Probability (%)].SetFocus
End Select

End Sub

Someone please help!

Thanks in advance,
Curtis King-Houston, TX
 
C

CurtisK-Houston, TX

For any who may be interested. Here is the reply I got back from Mr. B that
ultimately solved the problem:

Mr B said:
Ok, Curtis

Paste this code in the After Update event of the "Stage" combo box.

Select Case Stage
Case 4 'the "Won" option was selected
DoCmd.GoToControl "cboPrimaryWinReason"
Case 5 'the "Lost" option was selected
DoCmd.GoToControl "cboPrimaryLossReason"
Case Else 'some othere options was selected
DoCmd.GoToControl "txtWinProbability"
End Select

The problem was that the name of the combo box was not "cboStage" but it is >just "Stage".

That should at least correct that problem. At least it now works here and that is >all I did.


CurtisK-Houston said:
I have a combo box in a form that has five variables to select. If they
select "Won" it takes them to a different control near the bottom form, if
"Lost" is selected it takes them to yet another, however, if they select any
of the first three variables prior to "Won" and "Lost" it should simply take
the to the next control in the tab order on the form.

Here is the code I currently have in place:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
DoCmd.GoToControl "Primary Win Reason"
Case Is = Lost
DoCmd.GoToControl "Primary Loss Reason"
Case Else
DoCmd.GoToControl "Win Probability (%)"
End Select
End Sub

All this succeeds in doing is taking the user to the "Primary Win Reason"
control on the form regardless of which of the 5 variables they chose.

I also get similar results with the following code:

Private Sub Stage_AfterUpdate()
Select Case cboStage
Case Is = Won
Me![Primary Win Reason].SetFocus
Case Is = Lost
Me![Primary Loss Reason].SetFocus
Case Else
Me![Win Probability (%)].SetFocus
End Select

End Sub

Someone please help!

Thanks in advance,
Curtis King-Houston, TX
 

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