Baising of One combo box on another by value list

A

Azhar

I have one combo box (Cadre) having two fixed values Ministerial & Executive
at rowsource with "Value list" at rowsourcetype.
I wanted to have list of fixed values in the second combo box (rank) i.e the
ranks related with Ministerial cadre and ranks related with executive cadre.

I have put these code in (after update procedure) in the second combo box
(access 2002-03)

Private Sub Rank_AfterUpdate()
If Me.Cadre.Text = Executive Then
Me.Rank.RowSourceType = "value List"
Me.Rank.RowSource = "sp;dsp;ip"
Else
If Me.Cadre.Text = Ministerial Then
Me.Rank.RowSourceType = "value List"
Me.Rank.RowSource = "DD;SA;AD;CP"
End If
End If
End Sub

but it is not working, can any one can help/guide me in doing so.
 
J

Jeanette Cunningham

Azhar,
try it like this, the code needs to go on the after update of the combo
called cadre, not as you had with the combo called Rank.

Private Sub Cadre_AfterUpdate()
If Me.Cadre= Executive Then
Me.Rank.RowSourceType = "value List"
Me.Rank.RowSource = "sp;dsp;ip"
Else
If Me.Cadre= Ministerial Then
Me.Rank.RowSourceType = "value List"
Me.Rank.RowSource = "DD;SA;AD;CP"
End If
End If
End Sub


Jeanette Cunningham -- Melbourne Victoria Australia
 
F

fredg

I have one combo box (Cadre) having two fixed values Ministerial & Executive
at rowsource with "Value list" at rowsourcetype.
I wanted to have list of fixed values in the second combo box (rank) i.e the
ranks related with Ministerial cadre and ranks related with executive cadre.

I have put these code in (after update procedure) in the second combo box
(access 2002-03)

Private Sub Rank_AfterUpdate()
If Me.Cadre.Text = Executive Then
Me.Rank.RowSourceType = "value List"
Me.Rank.RowSource = "sp;dsp;ip"
Else
If Me.Cadre.Text = Ministerial Then
Me.Rank.RowSourceType = "value List"
Me.Rank.RowSource = "DD;SA;AD;CP"
End If
End If
End Sub

but it is not working, can any one can help/guide me in doing so.

If the Rank combo's RowSourceType property is going to be "Value List"
for either selection in the Cadre combo box, just set the Rank
RowSourceType property to "Value List" (on the Rank combo box property
sheet). No need to then specify it each time.

Also, in Access, it's the Value property you need to compare, not the
Text property.
An Access control has a Text property only as you are entering data
into that control. Once you exit the control (and the data is saved)
it becomes the control's Value property. So, after you select
"Executive" or "Ministerial" and exit the control to click on the next
control it is the combos Value. Because Value is a control's default
property there is no need to explicitly state it.

As "Executive" and "Ministerial" are both text values they must be
enclosed within quotes when referring to them.

And as there are just 2 possible choices in Cadre, if it's selected
value is not "Executive" then it must be the other value. No need to
use 2 criteria.

Code the Cadre AfterUpdate event:

If Me.Cadre="Executive" Then
Me.Rank.Rowsource = "sp;dsp;ip"
Else
Me.Rank.Rowsource = "DD;SA;AD;CP"
End If
 

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