Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Specified field could refer to more than one table..

Posted on 2013-01-10
7
Medium Priority
?
731 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 2000 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
Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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.

721 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