Hi There.
I'm trying to put a little app together that allows me to synchronise a combo box with a list box. I want to make a selection from the combo box and have only data related to it appear in the list box. I can get it to work when the primary and foreign keys are both numbers in a test application but the actual database this app will be used in has text data types for the keys and it does not seem to work with this data type. This is an historic artifact of our database and can't be changed. So, in the code below, [ProgrammeID] might be 'AB001'. Is there anything I can do to modify the code to make it work with text data types? Any help would be appeciated.
Thanks
Private Sub cboProgrammes_AfterUpdate()
Dim strStudentSource As String
strStudentSource = "SELECT [tblStudents1].[StudentID]," & _
" [tblStudents1].[ProgrammeID]," & _
" [tblStudents1].[StudentName] " & _
"FROM tblStudents1 " & _
"WHERE [ProgrammeID] = " & Me.cboProgrammes.Value
Me.lboStudents.RowSource = strStudentSource
Me.lboStudents.Requery
End Sub
I'm trying to put a little app together that allows me to synchronise a combo box with a list box. I want to make a selection from the combo box and have only data related to it appear in the list box. I can get it to work when the primary and foreign keys are both numbers in a test application but the actual database this app will be used in has text data types for the keys and it does not seem to work with this data type. This is an historic artifact of our database and can't be changed. So, in the code below, [ProgrammeID] might be 'AB001'. Is there anything I can do to modify the code to make it work with text data types? Any help would be appeciated.
Thanks
Private Sub cboProgrammes_AfterUpdate()
Dim strStudentSource As String
strStudentSource = "SELECT [tblStudents1].[StudentID]," & _
" [tblStudents1].[ProgrammeID]," & _
" [tblStudents1].[StudentName] " & _
"FROM tblStudents1 " & _
"WHERE [ProgrammeID] = " & Me.cboProgrammes.Value
Me.lboStudents.RowSource = strStudentSource
Me.lboStudents.Requery
End Sub