Dynamically update value list - without a macro

C

Charlie

I am trying to dynamically update a value list, based on the results
from a previous combo box choice - I want all the code to be in the
'afterupdate' expression section of the initial combo box and so far
have:

=if([ComboBoxName]="option1"),[FormName].[ListBoxName].RowSource="option1,
option2"

and I get the error "invalid syntax"

any ideas?

thanks
 
S

SteveS

In your description, it sounds like you have 2 combo boxes. But in the
example you use ComboBoxName and ListBoxName.

Either way, try this code:
(watch for line wrap)

Private Sub InitialComboBox_AfterUpdate()
If Me.InitialComboBox = "option1" Then
Me.ListOrComboBoxName.RowSourceType = "Value list"
Me.ListOrComboBoxName.RowSource = "OptionA;OptionB;OptionC"
Else
Me.ListOrComboBoxName.RowSourceType = "Value list"
Me.ListOrComboBoxName.RowSource = "Oranges;Bananas;Onions"
End If
End Sub
 
C

Charlie

worked perfectly, thank you
In your description, it sounds like you have 2 combo boxes. But in the
example you use ComboBoxName and ListBoxName.

Either way, try this code:
(watch for line wrap)

Private Sub InitialComboBox_AfterUpdate()
If Me.InitialComboBox = "option1" Then
Me.ListOrComboBoxName.RowSourceType = "Value list"
Me.ListOrComboBoxName.RowSource = "OptionA;OptionB;OptionC"
Else
Me.ListOrComboBoxName.RowSourceType = "Value list"
Me.ListOrComboBoxName.RowSource = "Oranges;Bananas;Onions"
End If
End Sub



--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Charlie said:
I am trying to dynamically update a value list, based on the results
from a previous combo box choice - I want all the code to be in the
'afterupdate' expression section of the initial combo box and so far
have:

=if([ComboBoxName]="option1"),[FormName].[ListBoxName].RowSource="option1,
option2"

and I get the error "invalid syntax"

any ideas?

thanks
 

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