AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile
Hi guys, I would like to select all the records from Session 1 to Session 3 for a particular student. My code is as below: rs.Open "SELECT DISTINCT * FROM view_ModuleReg WHERE ((LastName) = '" & frmModuleReg_ReportMenu.cbStudentName.Text & "') AND ((SessionID) = '" & frmModuleReg_ReportMenu.cbSession_From.Text & "') AND ((SessionID) = '" & frmModuleReg_ReportMenu.cbSession_To.Text & "')", conn, adOpenStatic, adLockOptimistic Set drpt_StudentName_SessionN_ModuleReg.DataSource = rs It seems like it is not working.. Any idea on this? Thank you Gary
it will always return an empty recordset because you are using = with two different session IDs. try this rs.Open "SELECT DISTINCT * FROM view_ModuleReg WHERE ((LastName) = '" & frmModuleReg_ReportMenu.cbStudentName.Text & "') AND ((SessionID) >= '" & frmModuleReg_ReportMenu.cbSession_From.Text & "') AND ((SessionID) <= '" & frmModuleReg_ReportMenu.cbSession_To.Text & "')", conn, adOpenStatic, adLockOptimistic you can also use the BETWEEN statement just like: ...WHERE SessionID BETWEEN 1 AND 3 ____________________________ AndreaVB
Hi Admin, Thanks for your advice, it works successfully... Gary