T
TK
I have a multi select list box I'm trying to use to get old transcripts.
Here is the sql I'm trying to use:
'**** Build SQL for gathering all records for student
strSQL = "INSERT INTO tblTempTranscripts ( StudentID, ClassID, [Year],
Term1, Term2, Term3, FinalExam, Resit ) " _
& "SELECT tblStudentGrades_Archive.StudentID,
tblStudentGrades_Archive.ClassID, tblStudentGrades_Archive.Year,
tblStudentGrades_Archive.Term1, tblStudentGrades_Archive.Term2,
tblStudentGrades_Archive.Term3, tblStudentGrades_Archive.FinalExam,
tblStudentGrades_Archive.Resit " _
& "FROM tblStudentGrades_Archive " _
& "WHERE ((tblStudentGrades_Archive.StudentID)= " & Me.StudentID &
") AND (Not (tblStudentGrades_Archive.Term1) Is Null)) OR (Not
(tblStudentGrades_Archive.Term2) Is Null)) OR (Not
(tblStudentGrades_Archive.Term3) Is Null)) OR (Not
(tblStudentGrades_Archive.FinalExam) Is Null)) AND
((tblStudentGrades_Archive.Year) = "
For Each varItem In Me.lstYearLevel.ItemsSelected
strSQL = strSQL & Me.lstYearLevel.ItemData(varItem) & " OR
((tblStudentGrades_Archive.Year)= "
MsgBox Me.lstYearLevel.ItemData(varItem)
Next varItem
'Trim the end of strSQL
strSQL = Mid(strSQL, 1, Len(strSQL) - 37) & "))"
Debug.Print strSQL
CurrentProject.Connection.Execute strSQL
The problem is in the trim I think - If I select only one item in the list,
I get a "Extra ) in query ..." error. If I take one of those out at the end
of the trim, and I select more than one item I get the "missing ) ..." erro.
Can anyone help me?
Thanks in advance.
TK
Here is the sql I'm trying to use:
'**** Build SQL for gathering all records for student
strSQL = "INSERT INTO tblTempTranscripts ( StudentID, ClassID, [Year],
Term1, Term2, Term3, FinalExam, Resit ) " _
& "SELECT tblStudentGrades_Archive.StudentID,
tblStudentGrades_Archive.ClassID, tblStudentGrades_Archive.Year,
tblStudentGrades_Archive.Term1, tblStudentGrades_Archive.Term2,
tblStudentGrades_Archive.Term3, tblStudentGrades_Archive.FinalExam,
tblStudentGrades_Archive.Resit " _
& "FROM tblStudentGrades_Archive " _
& "WHERE ((tblStudentGrades_Archive.StudentID)= " & Me.StudentID &
") AND (Not (tblStudentGrades_Archive.Term1) Is Null)) OR (Not
(tblStudentGrades_Archive.Term2) Is Null)) OR (Not
(tblStudentGrades_Archive.Term3) Is Null)) OR (Not
(tblStudentGrades_Archive.FinalExam) Is Null)) AND
((tblStudentGrades_Archive.Year) = "
For Each varItem In Me.lstYearLevel.ItemsSelected
strSQL = strSQL & Me.lstYearLevel.ItemData(varItem) & " OR
((tblStudentGrades_Archive.Year)= "
MsgBox Me.lstYearLevel.ItemData(varItem)
Next varItem
'Trim the end of strSQL
strSQL = Mid(strSQL, 1, Len(strSQL) - 37) & "))"
Debug.Print strSQL
CurrentProject.Connection.Execute strSQL
The problem is in the trim I think - If I select only one item in the list,
I get a "Extra ) in query ..." error. If I take one of those out at the end
of the trim, and I select more than one item I get the "missing ) ..." erro.
Can anyone help me?
Thanks in advance.
TK