hi,
are you sure that Student_DB points to the same DB where qryTeacher exists?
try to use:
Set rstTeacher = currentDB.OpenRecordset(strSQLTeacher)
--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
"Tim" <(E-Mail Removed)> wrote in message
news:B9F8D616-700C-4598-99EE-(E-Mail Removed)...
> I try to use DAO to pull out two values from a query (qryTeacher). This
> query
> is created by combining four tables that have inner join relationships. In
> VBA, I wrote the codes as following (with all variables are already
> declared
> properly.)
>
> strSQLTeacher = "SELECT StudID, email FROM qryTeacher WHERE
> ((qryTeacher.StudID)='" & varStudID & "');"
> Set rstTeacher = Student_DB.OpenRecordset(strSQLTeacher)
>
> I got the error message saying that "database engine cannot find the input
> table or query, "qryTeacher". BTW, I use Windows Vista and Access 2007. I
> guess I have to write the full SQL statement that forms the query, not
> just
> the query name, qryTeacher, for strSQLTeacher. Please help! Thank you.
>
>