Solved

Specified field could refer to more than one table..

Posted on 2013-01-10
7
715 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
[X]
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
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

742 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