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