473,473 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

15 New Member
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 2063
Rabbit
12,516 Recognized Expert Moderator MVP
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
sschmidt460
15 New Member
Shouldnt it know which field i am referencing since i have specified using [table_name].equipment?
Aug 3 '15 #3
sschmidt460
15 New Member
and also I am setting them "=" to eachother allowing the reference to be the same?
Aug 3 '15 #4
jforbes
1,107 Recognized Expert Top Contributor
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
sschmidt460
15 New Member
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 Recognized Expert Moderator MVP
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 Recognized Expert Top Contributor
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
sschmidt460
15 New Member
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
sschmidt460
15 New Member
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 Recognized Expert Moderator MVP
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: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.