A
ArielZusya
I've got a form that has a two combo boxes (cmbType and cmbStage). I want to
populate cmbStage based on the value selected in cmbType. cmbType points to
the field tblMain.Type which is a lookup to tblType.ID_Type and tblType.Type.
There are four types in tblType. I figure I need code in my onload for the
form and in my afterupdate for cmbType. I tried the following code in each:
Me.cmbStage.RowSourceType = "Value List"
If Me.cmbType.Value = 1 Then
Me.cmbStage.RowSource = "Pre;Group"
ElseIf Me.cmbType.Value = 2 Then
Me.cmbStage.RowSource = "Pre;Individual;Group"
ElseIf Me.cmbType.Value = 3 Then
Me.cmbStage.RowSource = "Pre;Individual;Group"
ElseIf Me.cmbType.Value = 4 Then
Me.cmbStage.RowSource = "Pre;Group"
End If
Me.cmbStage.ControlSource = "Stage"
Instead of providing me either
Pre
Group
or
Pre
Individual
Group
in cmbStage I get:
[tblStage].[Stage] FROM tblStage ORDER BY [ID_Stage]
and when selected I get an error about the value not being valid for the
field. The reason the value wouldn't be valid is that the value isn't a
number and the field (a lookup) is a number. I then commented out the
Me.cmbStage.ControlSource = "Stage"
line and now the combo box only shows me an unintended list: if my list
contained two values, it only shows me the second value; if it contained
three values, it only shows me the second value and then a blank value after
that. What am I doing wrong? Ultimately I'd like to be able to store the
result in tblStage.Stage which means I need to have a number with my value
and I'd like the number to be 1 for pre, 2 for Individual, and 3 for group.
Your help is greatly appreciated. Thanks!
populate cmbStage based on the value selected in cmbType. cmbType points to
the field tblMain.Type which is a lookup to tblType.ID_Type and tblType.Type.
There are four types in tblType. I figure I need code in my onload for the
form and in my afterupdate for cmbType. I tried the following code in each:
Me.cmbStage.RowSourceType = "Value List"
If Me.cmbType.Value = 1 Then
Me.cmbStage.RowSource = "Pre;Group"
ElseIf Me.cmbType.Value = 2 Then
Me.cmbStage.RowSource = "Pre;Individual;Group"
ElseIf Me.cmbType.Value = 3 Then
Me.cmbStage.RowSource = "Pre;Individual;Group"
ElseIf Me.cmbType.Value = 4 Then
Me.cmbStage.RowSource = "Pre;Group"
End If
Me.cmbStage.ControlSource = "Stage"
Instead of providing me either
Pre
Group
or
Pre
Individual
Group
in cmbStage I get:
[tblStage].[Stage] FROM tblStage ORDER BY [ID_Stage]
and when selected I get an error about the value not being valid for the
field. The reason the value wouldn't be valid is that the value isn't a
number and the field (a lookup) is a number. I then commented out the
Me.cmbStage.ControlSource = "Stage"
line and now the combo box only shows me an unintended list: if my list
contained two values, it only shows me the second value; if it contained
three values, it only shows me the second value and then a blank value after
that. What am I doing wrong? Ultimately I'd like to be able to store the
result in tblStage.Stage which means I need to have a number with my value
and I'd like the number to be 1 for pre, 2 for Individual, and 3 for group.
Your help is greatly appreciated. Thanks!