G
Guest
Hi All, I am trying to create a series of toggle buttons followed by
cascading combo boxes. The goal is to assign each combo box with a default
value after they have been populated with data. The reason for using default
values is to keep a user from having to re-enter data every time the combo
boxes are traversed. Each of the combo box default values are from data
found in the combo boxes. This is why the “Limit To List†Property is used
(line 5-7).
The toggle button populates the first combo box (lines 11-14) with data and
then assigns a default value to the first field of the first combo box (line
17).
Next, the first combo box populates the second combo box with data (lines
21-24) and then assigns a default value to the first field (line 27) of the
second combo box. This process is repeated for the second combo box.
When the toggle button subroutine tries to assign a default value to the
combo box (line 17), I get the following error: “Run-Time Error ‘2115’ -
The macro or function set to the BeforeUpdate or ValidationRul property for
this field is preventing MS Office from saving the data in the field.â€
The toggle button is activated by the “On Click†event and the combo boxes
are activated by an “After Update†event.
Each combo box “Row Source†property is set to “Value Listsâ€
If you have any suggestions on how to solve this problem, your answers will
be greatly appreciated.â€
1. Option Compare Database
2. Option Explicit
3.
4. Private Sub Form_Load()
5. Me.Combo1.LimitToList = True
6. Me.Combo2.LimitToList = True
7. Me.Combo3.LimitToList = True
8. End Sub
9.
10. Private Sub Toggle_Button_Click()
11. Me.Combo1.AddItem "test 1"
12. Me.Combo1.AddItem "test 2"
13. Me.Combo1.AddItem "test 3"
14. Me.Combo1.AddItem "test 4"
15.
16. Me.Combo1.SetFocus
17. Me.Combo1.Text = "test 1"
18. End Sub
19.
20. Private Sub Combo1_AfterUpdate()
21. Me.Combo2.AddItem "test 1-1"
22. Me.Combo2.AddItem "test 1-2"
23. Me.Combo2.AddItem "test 1-3"
24. Me.Combo2.AddItem "test 1-4"
25.
26. Me.Combo3.SetFocus
27. Me.Combo3.Text = "test 1-1"
28. End Sub
29.
30. Private Sub Combo2_AfterUpdate()
31. Me.Combo3.AddItem "test 1-1 a"
32. Me.Combo3.AddItem "test 1-1 b"
33. Me.Combo3.AddItem "test 1-1 c"
34. Me.Combo3.AddItem "test 1-1 d"
35. End Sub
Regards, Eddie Eytchison
cascading combo boxes. The goal is to assign each combo box with a default
value after they have been populated with data. The reason for using default
values is to keep a user from having to re-enter data every time the combo
boxes are traversed. Each of the combo box default values are from data
found in the combo boxes. This is why the “Limit To List†Property is used
(line 5-7).
The toggle button populates the first combo box (lines 11-14) with data and
then assigns a default value to the first field of the first combo box (line
17).
Next, the first combo box populates the second combo box with data (lines
21-24) and then assigns a default value to the first field (line 27) of the
second combo box. This process is repeated for the second combo box.
When the toggle button subroutine tries to assign a default value to the
combo box (line 17), I get the following error: “Run-Time Error ‘2115’ -
The macro or function set to the BeforeUpdate or ValidationRul property for
this field is preventing MS Office from saving the data in the field.â€
The toggle button is activated by the “On Click†event and the combo boxes
are activated by an “After Update†event.
Each combo box “Row Source†property is set to “Value Listsâ€
If you have any suggestions on how to solve this problem, your answers will
be greatly appreciated.â€
1. Option Compare Database
2. Option Explicit
3.
4. Private Sub Form_Load()
5. Me.Combo1.LimitToList = True
6. Me.Combo2.LimitToList = True
7. Me.Combo3.LimitToList = True
8. End Sub
9.
10. Private Sub Toggle_Button_Click()
11. Me.Combo1.AddItem "test 1"
12. Me.Combo1.AddItem "test 2"
13. Me.Combo1.AddItem "test 3"
14. Me.Combo1.AddItem "test 4"
15.
16. Me.Combo1.SetFocus
17. Me.Combo1.Text = "test 1"
18. End Sub
19.
20. Private Sub Combo1_AfterUpdate()
21. Me.Combo2.AddItem "test 1-1"
22. Me.Combo2.AddItem "test 1-2"
23. Me.Combo2.AddItem "test 1-3"
24. Me.Combo2.AddItem "test 1-4"
25.
26. Me.Combo3.SetFocus
27. Me.Combo3.Text = "test 1-1"
28. End Sub
29.
30. Private Sub Combo2_AfterUpdate()
31. Me.Combo3.AddItem "test 1-1 a"
32. Me.Combo3.AddItem "test 1-1 b"
33. Me.Combo3.AddItem "test 1-1 c"
34. Me.Combo3.AddItem "test 1-1 d"
35. End Sub
Regards, Eddie Eytchison