Solved Too many fields defined (1 Viewer)

KitaYama

Well-known member
Local time
Today, 18:10
Joined
Jan 6, 2022
Messages
1,541
I have this query

SQL:
SELECT
      UnitPrice*Quantity AS Price,
      o.Delivery,
      o.ReID,
      p.DrawingNo,
      p.DrawingName
FROM
      tblOrders AS o INNER JOIN tblProducts AS p
      ON o.OrderProductFK = p.ProductPK
WHERE
      UnitPrice*Quantity>1000000
      AND o.Delivery>#10/30/2023#
      AND o.SetName Is Null
      AND o.OrderedFrom_FK=268
ORDER BY
      UnitPrice*Quantity DESC
;

This query shows the correct data.
If I select External Data -> Export To Excel I receive the following error.

too many fields defined.

If I delete p.DrawingName from query, export to excel works without any error.
If I substitute p.DrawingName with any other fields, again the same error shows up and export fails.

Both tables are linked table to sql server.
The query shows 252 records if double clicked and opened.

From Excel I can import the query without any problem.

Is there any limitation on the number of fields when exporting a query to Excel?
Thanks.
 

June7

AWF VIP
Local time
Today, 01:10
Joined
Mar 9, 2014
Messages
5,472
The only limit is the Access limit of 255 fields in table or query.
 

KitaYama

Well-known member
Local time
Today, 18:10
Joined
Jan 6, 2022
Messages
1,541
tblOrders has 45 fields
tblProducts has 33 fields

Even if I sum them up, it's less than 255.

Thanks.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:10
Joined
May 21, 2018
Messages
8,529
I would
Compact and repair
Close access
reboot your machine

If that does not work maybe try

 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:10
Joined
Feb 19, 2002
Messages
43,275
I thought that once you added a table alias, you always had to alias columns from that table. Try changing all the references to UnitPrice and Quantity to o.UnitPrice and o.Quantity. I assume that's the table they're coming from.
 

June7

AWF VIP
Local time
Today, 01:10
Joined
Mar 9, 2014
Messages
5,472
I tested. No table prefix is needed for any of the fields. Access will add them in Design View for fields not involved in calc but calc still works. I have no problem with export.
 

KitaYama

Well-known member
Local time
Today, 18:10
Joined
Jan 6, 2022
Messages
1,541
I thought that once you added a table alias, you always had to alias columns from that table. Try changing all the references to UnitPrice and Quantity to o.UnitPrice and o.Quantity. I assume that's the table they're coming from.
As confirmed by @June7 the alias can be omitted. I tested again as you suggested just to be sure. No difference. The same error.

@ebs17 no, I don't. I 'm using ribbon's Export command (External Data).

Thanks.
 

KitaYama

Well-known member
Local time
Today, 18:10
Joined
Jan 6, 2022
Messages
1,541
I think I was able to solve the problem.

Ever since I installed the addin in Custom Ribbon Creator for Access 2019 and 2021 ,I had serious problems with Access.

All my addins were vanished, a lot of settings were changed. Even action queries didn't show the warning messages.
Some of these problems were confirmed by other members too. It was suggested to install the addin with running Access as Admin.

I uninstalled and reinstalled Office.
Now, everything's just OK. No error while exporting the query.

I really appreciate all for trying to help.
Million thanks.
 

ebs17

Well-known member
Local time
Today, 11:10
Joined
Feb 7, 2020
Messages
1,946
I 'm using ribbon's Export command
I'm a little surprised. If I otherwise do a lot of fine programming, I don't expose a user to basic Access functionality unaccompanied and unprotected somewhere else.
 

KitaYama

Well-known member
Local time
Today, 18:10
Joined
Jan 6, 2022
Messages
1,541
I'm a little surprised. If I otherwise do a lot of fine programming, I don't expose a user to basic Access functionality unaccompanied and unprotected somewhere else.
I'm sorry but I'm not sure if I can understand what you mean.
Do you mean why I'm using the ribbon and not programmatically exporting the data?

If it's so, it's a only-one-time action and not something that needs to be done on a specific routine.
One of our customers had asked for a report and some graphs for their orders (as a test). We wanted to offer something and if they accept the result, then a new feature will be added to FE. At this point we're not sure what their reply would be. For now we're only experimenting.
Hence at this stage, it was only a shot in the dark to see how their response would be.

If you meant something else, any further explanation would be great.
Thanks.
 
Last edited:

spaLOGICng

Member
Local time
Today, 02:10
Joined
Jul 27, 2012
Messages
127
I have this query

SQL:
SELECT
      UnitPrice*Quantity AS Price,
      o.Delivery,
      o.ReID,
      p.DrawingNo,
      p.DrawingName
FROM
      tblOrders AS o INNER JOIN tblProducts AS p
      ON o.OrderProductFK = p.ProductPK
WHERE
      UnitPrice*Quantity>1000000
      AND o.Delivery>#10/30/2023#
      AND o.SetName Is Null
      AND o.OrderedFrom_FK=268
ORDER BY
      UnitPrice*Quantity DESC
;

This query shows the correct data.
If I select External Data -> Export To Excel I receive the following error.

too many fields defined.

If I delete p.DrawingName from query, export to excel works without any error.
If I substitute p.DrawingName with any other fields, again the same error shows up and export fails.

Both tables are linked table to sql server.
The query shows 252 records if double clicked and opened.

From Excel I can import the query without any problem.

Is there any limitation on the number of fields when exporting a query to Excel?
Thanks.
You can export all fields via vba using DAO and the copyrecordset method.
 

Users who are viewing this thread

Top Bottom