Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Specified field could refer to more than one table..

Posted on 2013-01-10
7
711 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

856 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