Synchronising Combo Boxes

AmyB

New member
Local time
Today, 13:39
Joined
May 12, 2004
Messages
8
On a sub-form I have two cascading combo boxes; cboParent which allows the user to select a year and cboChild which then allows the user to select a course dependent on the year selected in cboParent. I created these using Mile-o-Phile's method in the FAQ here.
However, when I scroll back through the records only the course names that relate to the last selected year show up on the top row of the cboChild box. I need to see the course name that was selected on all the records.
I have tried to use the following code to synchronise them, but it causes a "compile error" when I run the form.

Code:
Private Sub Form_Current ()
   On Error Resume Next
   cboParent = DLookup("[YearID]", "SSAllCourses", "[CourseID]='" & cboChild.Value & "'")
   cboChild.RowSource = "Select SSAllCourses.CourseID " & _
            "FROM SSAllCourses " & _
            "WHERE SSAllCourses.YearID = '" & cboParent.Value & "' " & _
            "ORDER BY SSAllCourses.CourseID;"
End Sub

End Sub

The code came from http://www.fontstuff.com/access/acctut10.htm if that's any help.

Thanks in advance,
Amy
 
You have a double end sub.... which is the problem if you pasted the code directly....

BR
 
Thanks, but that's not it. I've taken out the second End Sub and it still causes a compile error. I'm a novice and I'm absolutely stumped with this so any other help would be hugely appreciated.

Thanks.
 
Sorted it!

Through trial and error, I worked out that

Code:
Sub Form_Current ()
cboParent.Requery
cboChild.Requery

End Sub

does the trick. Just thought I'd post it in case anyone else is having this difficulty.
 

Users who are viewing this thread

Back
Top Bottom