Solved

Specified field could refer to more than one table..

Posted on 2013-01-10
7
683 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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 61

Expert Comment

by:mbizup
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Glad to help out :)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now