My 2 comboboxes (see attached doc.) are bound by StudentID
Combo box #1 is student number which shows both student number followed by student name. Student ID is not visible.
Combo box #2 is student name and shows both student name followed by student number. StudentID is not visible.
I have a code that updates the combo boxes based on the selection in either box. If I select the number in box #1 then the name of the student will automatically appear in the box #2. Here's the code I'm using for that:
Code:
Option Compare Database
Private Sub Combo4_AfterUpdate()
Combo6.Value = Combo4.Value
DoCmd.SearchForRecord , "", acFirst, "StudentID = " & str(Nz([Screen].[ActiveControl], 0))
End Sub
Private Sub Combo6_AfterUpdate()
Combo4.Value = Combo6.Value
DoCmd.SearchForRecord , "", acFirst, "StudentID = " & str(Nz([Screen].[ActiveControl], 0))
End Sub
Here's the SQL for the report query:
Code:
SELECT Student.StudentNumber, Student.StudentID, Student.StudentLastName & ", " & StudentFirstName & " " & StudentMiddleName AS StudentFullName, Student.StudentReligiousName, a.ProgramID, Student.StudentSSN, Student.StudentDOB, a.CourseCode, a.CourseName, a.Unit, a.Grade, a.GradePoint, a.Year, a.TermID, StudentMailingAddress.Address & ", " & StudentMailingAddress.City & ", " & StudentMailingAddress.[State/Province] & " " & StudentMailingAddress.[ZIP/PostalCode] AS StudentFullAddress, a.GradeValidUnit, a.GradeValidPoint
FROM StudentAllCoursesInActiveProgram AS a LEFT JOIN (Student LEFT JOIN StudentMailingAddress ON Student.StudentID = StudentMailingAddress.StudentID) ON a.StudentID = Student.StudentID
WHERE (((Student.StudentNumber)=[Forms]![ParamForm]![Combo4]));