Solved

Specified field could refer to more than one table..

Posted on 2013-01-10
7
713 Views
Last Modified: 2013-01-10
I have a report that uses a (fairly complex) query.  It runs fine by itself but when called by running a report, it gives the "Specified field could refer to more than one table.." error.

I have looked at the SQL and just cannot figure out what to do to solve this problem.

The SQL of the query looks like this:#
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

SELECT tblVolunteers.[Vol ID], tblJobs.[Date completed], tblVolunteers!Firstname & " " & tblVolunteers!Lastname AS Fullname, tblClients![Address 1] & ", " & tblClients![Address 2] & ", " & tblClients!Town & ", " & tblClients!Postcode AS ClientAddress, tblJobs.[Job ID], tblJobVolLink.HoursWorked, rptqryVolunteersJobsAllGroupTotals.[CountOfJob ID], rptqryVolunteersJobsAllGroupTotals.SumOfHoursWorked
FROM rptqryVolunteersJobsAllGroupTotals INNER JOIN (tblVolunteers INNER JOIN ((tblClients INNER JOIN tblJobs ON tblClients.[Client ID] = tblJobs.[Client ID]) INNER JOIN tblJobVolLink ON tblJobs.[Job ID] = tblJobVolLink.[Job ID]) ON tblVolunteers.[Vol ID] = tblJobVolLink.[Vol ID]) ON rptqryVolunteersJobsAllGroupTotals.[Vol ID] = tblJobVolLink.[Vol ID]
WHERE (((tblJobs.[Date completed]) Between [forms]![menufrmAnalysisReports]![Start Date] And [forms]![menufrmAnalysisReports]![End Date]))
ORDER BY tblJobs.[Date completed];

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Any ideas?

Regards

Richard
0
Comment
Question by:rltomalin
  • 4
  • 2
7 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38762225
as the query refers to the form (and it's record source), you cannot run this as a report directly, as then it cannot resolve the form (which may not even be open at that time)...

so, you have to remove the form references, and eventually replace them by a table containing the data.
0
 

Author Comment

by:rltomalin
ID: 38762258
Thanks for the prompt feedback.
 
I have removed the date filter which refers to a form.
The SQL now looks like this:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

SELECT tblVolunteers.[Vol ID], tblJobs.[Date completed], tblVolunteers!Firstname & " " & tblVolunteers!Lastname AS Fullname, tblClients![Address 1] & ", " & tblClients![Address 2] & ", " & tblClients!Town & ", " & tblClients!Postcode AS ClientAddress, tblJobs.[Job ID], tblJobVolLink.HoursWorked, rptqryVolunteersJobsAllGroupTotals.[CountOfJob ID], rptqryVolunteersJobsAllGroupTotals.SumOfHoursWorked
FROM rptqryVolunteersJobsAllGroupTotals INNER JOIN (tblVolunteers INNER JOIN ((tblClients INNER JOIN tblJobs ON tblClients.[Client ID] = tblJobs.[Client ID]) INNER JOIN tblJobVolLink ON tblJobs.[Job ID] = tblJobVolLink.[Job ID]) ON tblVolunteers.[Vol ID] = tblJobVolLink.[Vol ID]) ON rptqryVolunteersJobsAllGroupTotals.[Vol ID] = tblJobVolLink.[Vol ID]
ORDER BY tblJobs.[Date completed];

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

But the situation is still the same I am afraid.

Regards

Richard
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 38762269
Try this modification:

SELECT v.[Vol ID], j.[Date completed], v.Firstname & " " & v.Lastname AS VolunteerFullname, c.[Address 1] & ", " & c.[Address 2] & ", " & c.Town & ", " & c.Postcode AS NewClientAddress, j.[Job ID], vl.HoursWorked, rpt.[CountOfJob ID], rpt.SumOfHoursWorked
FROM rptqryVolunteersJobsAllGroupTotals  rpt INNER JOIN (tblVolunteers v INNER JOIN ((tblClients c INNER JOIN tblJobs j ON c.[Client ID] = j.[Client ID]) INNER JOIN tblJobVolLink vl ON j.[Job ID] = vl.[Job ID]) ON v.[Vol ID] = vl.[Vol ID]) ON rpt.[Vol ID] = vl.[Vol ID]
WHERE (((j.[Date completed]) Between [forms]![menufrmAnalysisReports]![Start Date] And [forms]![menufrmAnalysisReports]![End Date]))
ORDER BY j.[Date completed];

Open in new window


You need your Access form menufrmAnalysisReports open when you run this query.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 61

Expert Comment

by:mbizup
ID: 38762282
Just explaining the changes -  I used short aliases for the table names to shorten the overall syntax and replaced ! with . in your table/field references.

I also renamed your field aliases to VolunteerFullname and NewClientAddress thinking that one of your original aliases may have possibly been repeating a field name from another table or query.  The aliases are the only fields that weren't explicitly prefixed with a table name - so that just strikes me as the most likely place where a "Specified field could refer to more than one table".
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38762322
Also check how you have set the control source properties for the textboxes, etc in your report's design.  In some cases you may need to include a table prefix with your field name in the control source property.

If you look at your report in design view, you should see green triangles in the upper left hand corner of any textboxes etc whose control sources are not recognized.

ALSO verify that the field names in your report's sorting and grouping are not ambiguous.
0
 

Author Closing Comment

by:rltomalin
ID: 38762494
Hi mbizup

Sorry for the delay in getting back to you.  I have been in a meeting - taking me away from the interesting stuff!!

I have changed the query and gone through the report and changed the control sources.

All seems to work fine now.  Excellent solution, thanks very much.

Best regards

Richard
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38762512
Glad to help out :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question