I have 2 queries, qryDept and qryExams. Because I can not join these queries together so I have to use 2 Record sets in ASP.

The NoStudents deduct from NoExams to get Remain.

It keeps getting errors at the --oRs2.Open strSQL2, Conn.

<% Dim Dept_ID, strSQL2, oRs2, Remain
		strSQL = "SELECT Dept_ID, NoStudents FROM qryDept; " & _
		strSQL2 = "SELECT Dept_ID, NoExams FROM qryExams " & _
			" Where = qryExams.Dept_ID = qryDept.Dept_ID;"
		Set oRs = Server.CreateObject("adodb.RecordSet")
		oRs.Open strSQL, Conn
		Set oRs2 = Server.CreateObject("adodb.RecordSet")
		oRs2.Open strSQL2, Conn
		if not oRs.eof then	%>
				<%	do until oRs.eof %>
				<% if not oRs2.eof then	%>
				<%	do until oRs2.eof %>
				<% Remain = <%=oRs("NoStudents")%>-<%=oRs2("NoExams")%>%>
				<%	oRs2.MoveNext
					loop	%>
		<%	end if	%>
				<%	oRs.MoveNext
					loop	%>
		<%	end if	%>

Errors: Too few parameters. Expected 1. at Line ---oRs2.Open strSQL2, Conn

Can anyone please help how to fix this code to make it work?

Thanks very much and have a nice day.

I'd say the extra '=' sign here is causing your problem

Where = qryExams.Dept_ID

Edit: Well, and the fact you can't refer to "qryDept.Dept_ID" if you haven't joined to qryDept in that query. In short, your second SQL statement is completely invalid.

still not working. I think the asp code I used is incorrect or something.
Is there another way to coding to fix this issue?