You are using a constant, not a variable in your Filter statement:

Change this:

rst.Filter "StudentNam ='temp'"

To this:

rst.Filter "StudentNam ='" & temp & "'"