PC Review


Reply
Thread Tools Rate Thread

DAO: query of multiple tables can not find

 
 
Tim
Guest
Posts: n/a
 
      13th Jan 2010
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.


 
Reply With Quote
 
 
 
 
Alex Dybenko
Guest
Posts: n/a
 
      13th Jan 2010
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.
>
>

 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      13th Jan 2010
Hi Alex, Yes, I am sure. It's declared already somewhere. So can you point
out for me what is the problem now? Thanks.

"Alex Dybenko" wrote:

> 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.
> >
> >

> .
>

 
Reply With Quote
 
Alex Dybenko
Guest
Posts: n/a
 
      14th Jan 2010
Hi,
what about currentDB.OpenRecordset(strSQLTeacher) - is it working at you?
This error can also occur if you create qryTeacher AFTER initializing
Student_DB variable

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com



"Tim" <(E-Mail Removed)> wrote in message
news:1C9B162C-7BB8-446A-9639-(E-Mail Removed)...
> Hi Alex, Yes, I am sure. It's declared already somewhere. So can you point
> out for me what is the problem now? Thanks.
>
> "Alex Dybenko" wrote:
>
>> 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.
>> >
>> >

>> .
>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and replace data in multiple tables Dave Microsoft Access 4 10th Mar 2006 07:42 PM
Re: Can I update tables from a form using query with multiple tables? John Vinson Microsoft Access 0 8th Sep 2004 11:45 PM
can't find tables used in query Buboy Microsoft Access Queries 3 26th Apr 2004 04:31 AM
Find the right tables to Query???? Steve B Microsoft Access Queries 1 12th Apr 2004 11:01 PM
Find fields in multiple tables Vic Microsoft Access 1 15th Oct 2003 01:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:42 PM.