473,386 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

I try and open a form and it gives the error given below

The specified field [Equipment] could refer to more than one table listed in the FROM clause of your SQL statement

Expand|Select|Wrap|Line Numbers
  1. SELECT [Inventory Table].*, [Inventory Table].Part, [Equipment List Table].Equipment, Nz(DSum("[Quantity]","[Return Table]","[Part]='" & [Forms]![Inventory Form].[Part Text] & "'"))-Nz(DSum("[Quantity]","[Requisition Table]","[Part]='" & [Forms]![Inventory Form].[Part Text] & "'"))+Nz(DSum("[Quantity]","[Add Stock Table]","[Part]='" & [Forms]![Inventory Form].[Part Text] & "'"))+Nz(DSum("[Quantity]","[Adjustment Table]","[Part]='" & [Forms]![Inventory Form].[Part Text] & "'"))+Nz(DSum("[Quantity on Hand]","[Inventory Table]","[Part]='" & [Forms]![Inventory Form].[Part Text] & "'")) AS [Current]
  2. FROM [Equipment List Table] INNER JOIN ([Inventory Table] INNER JOIN [Equipment Parts Table] ON [Inventory Table].Part = [Equipment Parts Table].Part) ON [Equipment List Table].Equipment = [Equipment Parts Table].Equipment
  3. ORDER BY [Inventory Table].Part;
Aug 3 '15 #1
10 2062
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data.

You have more than one field with the same name. When you try to reference one of them, it's not going to know which one you mean to use. In this case, you are returning 2 fields with the name Equipment. And when you try to reference that field in the form, it doesn't know which of the two fields you are talking about. Also, you're returning the field Part twice.

As a side note, you should avoid domain aggregate functions when possible, they tend to be poor performers.
Aug 3 '15 #2
Shouldnt it know which field i am referencing since i have specified using [table_name].equipment?
Aug 3 '15 #3
and also I am setting them "=" to eachother allowing the reference to be the same?
Aug 3 '15 #4
jforbes
1,107 Expert 1GB
This:
Expand|Select|Wrap|Line Numbers
  1. FROM [Equipment List Table] 
  2. INNER JOIN ([Inventory Table] 
  3. INNER JOIN [Equipment Parts Table] 
  4. ON [Inventory Table].Part = [Equipment Parts Table].Part) 
  5. ON [Equipment List Table].Equipment = [Equipment Parts Table].Equipment
Probably should be more like this:
Expand|Select|Wrap|Line Numbers
  1. FROM [Equipment List Table] 
  2. INNER JOIN ([Inventory Table] 
  3. ON [Inventory Table].Part = [Equipment Parts Table].Part) 
  4. INNER JOIN [Equipment Parts Table] 
  5. ON [Equipment List Table].Equipment = [Equipment Parts Table].Equipment
Aug 3 '15 #5
I changed the code to jforbes suggestion, but there is now a "syntax error in the JOIN operation"
Aug 3 '15 #6
Rabbit
12,516 Expert Mod 8TB
It's going to know in the query, yes. But it's not going to know in your form. Because the form control isn't set with the table name referenced.

Aside from the fact that you shouldn't have two things in a query with the same name, why would you want duplicate columns anyways? They contain the same data, it creates confusion, and it makes things run a little slower.
Aug 3 '15 #7
jforbes
1,107 Expert 1GB
Yep, there is a typo, I didn't pay much attention to it the first time. Just assumed they were correct:
Expand|Select|Wrap|Line Numbers
  1. FROM [Equipment List Table] 
  2. INNER JOIN ([Inventory Table] 
  3. ON [Inventory Table].Part = [Equipment List Table].Part) 
  4. INNER JOIN [Equipment Parts Table] 
  5. ON [Equipment List Table].Equipment = [Equipment Parts Table].Equipment
Rabbit is right, you will probably want to specify which (unique) columns to use from which tables and leave off the duplicates. Things can get really messy using the Star... [Inventory Table].*
Aug 3 '15 #8
Expand|Select|Wrap|Line Numbers
  1. SELECT [Inventory Table].*, [Inventory Table].Part, Nz(DSum("[Quantity]","[Return Table]","[Part]='" & [Forms]![Inventory Form].[Part Text] & "'"))-Nz(DSum("[Quantity]","[Requisition Table]","[Part]='" & [Forms]![Inventory Form].[Part Text] & "'"))+Nz(DSum("[Quantity]","[Add Stock Table]","[Part]='" & [Forms]![Inventory Form].[Part Text] & "'"))+Nz(DSum("[Quantity]","[Adjustment Table]","[Part]='" & [Forms]![Inventory Form].[Part Text] & "'"))+Nz(DSum("[Quantity on Hand]","[Inventory Table]","[Part]='" & [Forms]![Inventory Form].[Part Text] & "'")) AS [Current], [Equipment Parts Table].Equipment
  2. FROM [Inventory Table] INNER JOIN [Equipment Parts Table] ON [Inventory Table].Part = [Equipment Parts Table].Part;
Aug 3 '15 #9
I revised it to this code to have only 1 field name "equipment" and the error remains the same. In the query I have gotten rid of one of the tables that contained the duplicate, but I still get the error. I dont understand how this can still be happening
Aug 3 '15 #10
Rabbit
12,516 Expert Mod 8TB
Your inventory table probably has a field named Equipment. You didn't have to remove the join by the way. It's not the join that's causing the problem. It's the fact that you're returning fields with the same name. You just need to give it an alias if you need both fields returned. Otherwise, just leave it out of the select clause.
Aug 3 '15 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: jeff | last post by:
Hi,guys. When I open an existed project, I got a problem.I do not know why? When I open a Form on my Solution: >>An error occurred while loading the document. Fix the error and then try...
4
by: Xiphias | last post by:
Hi, Hope you can help me on this... I got 1 form with a sub form. On this subform there are only parts of records, so you can select the one you want to edit. When you dubbel click that...
0
by: Pixie | last post by:
We are successfully getting a handle to a drive using createfile then using that handle to query the change journal using DeviceIOControl with the paramter FSCTL_QUERY_USN_DATA. However when we try...
1
by: Fred Morrison | last post by:
All of a sudden, any attempt to open any form that inherits from my base MID Child form gives this error: An error occurred while loading the document. Fix the error, and then try loading the...
2
by: allyn44 | last post by:
Hello, I have built a serch form for users to edit records. I only want them to pull up the record they need, and I want to check for nulls. There should not be dupes becasue the underlying...
6
by: ranesmitas | last post by:
Hi ,I am using Visual Basic Backend SQL I create form in which i create Command button NEW ,MODIFY, VIEW,SAVE,EXIT all my programme is running but when i add new record and save and then i...
2
by: Triciclo | last post by:
We have an Access 2002 Front End Database that will be used by 8 users to enter data. Each user has own copy on their own file in the shared drive. We have tried the Front End in 7 computers and...
0
by: rahulsankhe1089 | last post by:
I am using below javascript <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> <script type="text/javascript"> ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.