Hi Dirk, Thanks for taking my question.
Line 27 was a typeo, the new code is below. I added the code for combo box
3 and please note lines 36-37. I forgot to put then in the original message.
Once again, thanks for your help
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!Combo2.SetFocus
27. Me!Combo2.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.
36. Me!Combo3.SetFocus
37. Me!Combo3.Text = "test 1-1 a"
38.
39. End Sub
40.
41. Private Sub Combo3_AfterUpdate()
42. ' values filled by combo box 2
43. End Sub
"Dirk Goldgar" wrote:
> "Eddie's Bakery and Cafe'" <(E-Mail Removed)> wrote in message
> news:F776DC35-5DC0-4D19-B3F4-(E-Mail Removed)
> > 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
>
> Look at lines 26-27 again. They refer to Combo3, not Combo2.
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>
>