473,788 Members | 2,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query too Complex

8 New Member
Hello All! I have an update query that is rather large and I keep getting a "Query is too complex" error. Does anyone know the limitations on update queries for MS Access 2000? I am running on Windows XP. The query has about 95 actions (updates) for approximately 35 tables. Thank you for the info!

Sloney
Sep 2 '08 #1
11 1963
Stewart Ross
2,545 Recognized Expert Moderator Specialist
I think you have no choice but to break your query down into more manageable components; as you will see from the MS Knowledge Base article linked here, earlier versions of the JET database engine had a limit of 40 fields (now 99 fields) before a 'Query Too Complex' error would occur. The article explains why.

Anyhow, if you need 95 attributes updated it would help maintainability if nothing else to break it down into multiple updates that are run sequentially.

-Stewart
Sep 2 '08 #2
NeoPa
32,578 Recognized Expert Moderator MVP
I'm afraid I have no idea what the limitations are, but I would consider breaking this query into multiple queries if I had that many tables to update - or even to include when fewer tables are actually updated.

PS. Stewart nicked in there with a better answer anyway, although it's not too far what I was thinking (phew!)
Sep 2 '08 #3
sloney
8 New Member
Based on what I read this evening I should be able to run this update query as a Docmd RunSQL. Please straighten me out where I may misspeak or not clearly understand as I am a newbie.

Anyways, based on the MSDN website (http://msdn.microsoft. com/en-us/library/aa141546(office .10).aspx) it appears that "The maximum length of the sqlstatement argument is 32,768 characters (unlike the SQL Statement action argument in the Macro window, whose maximum length is 256 characters)."

My thought is that I should be able to run the desired query. When I brought it into SQL view there are just under 5000 characters. I could break it down but what fun is that! I need to use this query for 20+ databases that share the same table names and fields. If I could limit it to one or two query that would be most suitable. Sooo, it appears that I have some troubleshooting in front of me. Just recently I have tried using the Docmd RunSQL as a module in Access. I am trying to run a test on one table and build from there. Below is what I have and it keep getting a syntax error 3114.

Expand|Select|Wrap|Line Numbers
  1. Public Sub DoSQL()      
  2. Dim SQL As String          
  3.       SQL = "Update S_HYDRAMAPPING" & _     
  4.       "Set S_HYDRAMAPPING.MAPID = '0000'& MAPID"   
  5. DoCmd.RunSQL SQL  
  6. End Sub  
As I said I am a rookie so compiling is very new to me. Any advice would be helpful. Thanks folks!

Sloney
Sep 3 '08 #4
ADezii
8,834 Recognized Expert Expert
Based on what I read this evening I should be able to run this update query as a Docmd RunSQL. Please straighten me out where I may misspeak or not clearly understand as I am a newbie.

Anyways, based on the MSDN website (http://msdn.microsoft. com/en-us/library/aa141546(office .10).aspx) it appears that "The maximum length of the sqlstatement argument is 32,768 characters (unlike the SQL Statement action argument in the Macro window, whose maximum length is 256 characters)."

My thought is that I should be able to run the desired query. When I brought it into SQL view there are just under 5000 characters. I could break it down but what fun is that! I need to use this query for 20+ databases that share the same table names and fields. If I could limit it to one or two query that would be most suitable. Sooo, it appears that I have some troubleshooting in front of me. Just recently I have tried using the Docmd RunSQL as a module in Access. I am trying to run a test on one table and build from there. Below is what I have and it keep getting a syntax error 3114.

Expand|Select|Wrap|Line Numbers
  1. Public Sub DoSQL()      
  2. Dim SQL As String          
  3.       SQL = "Update S_HYDRAMAPPING" & _     
  4.       "Set S_HYDRAMAPPING.MAPID = '0000'& MAPID"   
  5. DoCmd.RunSQL SQL  
  6. End Sub  
As I said I am a rookie so compiling is very new to me. Any advice would be helpful. Thanks folks!

Sloney
These Specifications are for Access 2000
  1. Number of enforced relationships ==> 32 per table minus the number of indexes that are on the table for fields or combinations of fields that are not involved in relationships
  2. Number of tables in a query ==> 32
  3. Number of fields in a recordset ==> 255
  4. Recordset size 1 gigabyte
  5. Sort limit 255 characters in one or more fields
  6. Number of levels of nested queries ==> 50
  7. Number of characters in a cell in the query design grid ==> 1,024
  8. Number of characters for a parameter in a parameter query ==> 255
  9. Number of ANDs in a WHERE or HAVING clause ==> 40
  10. Number of characters in an SQL statement approximately ==> 64,000
Sep 3 '08 #5
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. ADezii has helpfully provided the exact specs for you. Regardless of whether or not you want to break the query down you really have no choice, as it undoubtedly exceeds the limits of the number of fields Access can update at once. It is also possible that it exceeds one of the other limitations (number of ANDs involved for instance). It is not the length of the query that is the problem (though I would shudder at the thought of reading - let alone understanding - a 5000 character SQL statement - how on earth can you verify that it performs correctly in all its aspects in all circumstances?? ?).

In any event, if you consider future maintainability by other persons you should redesign it so that it is understandable to other people. Once the update is broken down you can bring it together into a single sequential operation using either a macro to do so or VBA code, and distribute this to the other applications involved as appropriate.

-Stewart
Sep 3 '08 #6
FishVal
2,653 Recognized Expert Specialist
Hello, all.

Jet engine could crash with the same message in a case when query contains calculations, even not very complicated from human point of view. ;)
I've never seen specifications of that type of limitation, nor I have any personal clue about it.
The only reliable way, as others already stated, is to split down complex query into sequential parts and test them separately. Or, what is the same, build query again from scratch step-by-step and localize which addition cause it to fail.

You may read also Access msg Too complex thread concerning the same.

Regards,
Fish
Sep 3 '08 #7
NeoPa
32,578 Recognized Expert Moderator MVP
...
I am trying to run a test on one table and build from there. Below is what I have and it keep getting a syntax error 3114.

Expand|Select|Wrap|Line Numbers
  1. Public Sub DoSQL()      
  2. Dim SQL As String          
  3.       SQL = "Update S_HYDRAMAPPING" & _     
  4.       "Set S_HYDRAMAPPING.MAPID = '0000'& MAPID"
  5. DoCmd.RunSQL SQL  
  6. End Sub  
...
First of all I would say two things :
  1. Read Stewart's last response. It is unlikely you will manage to keep this as one item. It would be unwise even to try.
  2. When reporting errors, it's good practice to include the message as well as the number of the error. Not forgetting, of course, to include the line number in the posted code where the error occurs.
Moving on from there though, and looking specifically at your posted code, it is suffering from a very common problem when building up SQL strings in code. There is no white space before the "Set ". There is in the VBA code, but none is included in the SQL string.

A good trick here, until you find this more like second nature, is to add a Debug.Print line after the string has been formulated.
Expand|Select|Wrap|Line Numbers
  1. ...
  2. Debug.Print SQL
  3. DoCmd.RunSQL SQL
  4. ...
Other possible problems are no white space before the "&" and a possibly unrecognisable reference afterwards (MAPID).

To illustrate, the string would look like the following :
Expand|Select|Wrap|Line Numbers
  1. Update S_HYDRAMAPPINGSet S_HYDRAMAPPING.MAPID = '0000'& MAPID
Sep 3 '08 #8
ADezii
8,834 Recognized Expert Expert
One more point to consider, if you are breaking down your Query into multiple Update Querys, I would definitely think that you would want to wrap the entire process into a Transaction. I'm sure that if you ran into a situation where some of the Updates were successfully executed, while others failed, you would not be in a happy place. Either 'ALL' the Updates are a success or they 'ALL' fail.
Sep 3 '08 #9
NeoPa
32,578 Recognized Expert Moderator MVP
Good thinking Batman :)

That's almost certainly something you should implement.
Sep 3 '08 #10

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

Similar topics

3
3055
by: Brian Oster | last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a query that used to execute in under 2 seconds, now takes over 8 Minutes to complete. Any ideas on what the heck might be going on? I have tested this extensively and can say for certain that installing this hot fix is what has caused the performance problem. I just don't know why or how to fix it. Brian Oster
4
8977
by: Starbuck | last post by:
OK, first let me say that I am no DB person. But I have a user here who keeps getting this error whenever she does, whatever it is she does, with databases... A google search takes me to various forums where I am forced to sign up before I can read any answers. Interesting note here is that the guy in the office next
3
7881
by: Jonathan | last post by:
Hi all! For a match schedule I would like to find all possible combinations of teams playing home and away (without teams playing to themselves of course). I now the simple version works something like this: For a (very) simple table containing three rows like this: row 1: A
8
5068
by: Matt | last post by:
Hi all, Thank you for taking the time. I have a database with 45 tables on it. 44 tables are linked to a main table through a one to one relationship. My question is, is there no way i can have a query that will pull a single field from all the tables. In other words i should have 44 fields. when i try to do that same, i get an error message saying "Query is too complex"
2
1837
by: Ben de Vette | last post by:
Hi, I'm using the querybuilder when updating a record in a table (Access). However, I get a "Query is too complex" message. The Primary key is autonumbered. Why is it making such a complex update query string in stead of using the primary key? Thanks in advance,
9
2905
by: Jimbo | last post by:
Hello, I have a user request to build a form in an Access database where the user can check off specific fields to pull in a query. For example, let's say I have 10 fields in a table. The user wants to be able to check off anywhere between 1 and all 10 fields in a form and have it return a select query with just the fields that were checked off. There are multiple users, so not all users will be checking off the same fields. Some...
10
2111
by: Robert | last post by:
I am an attorney in a non-profit organization and a self-taught programmer. I'm trying to create a client db that will allow me to search for potential conflicts of interest based either on Social Security # or on Last Name. I've created two different tables with the following fields in each table: ClientInfo Client# (primary key) First Name Middle Name Last Name
1
2670
by: arun | last post by:
Query is too complex -------------------------------------------------------------------------------- Hi, I was trying to solve this problem since last two days but couldn't find any solution. I wanted to execute a query which is retrieving the records from table1 by checking the condition for a long long string . I'm using where clause and checking the condition as-
8
6725
by: babyangel43 | last post by:
Hello, I have a query set up in Access. I run it monthly, changing "date of test". I would like this query to be merged with a Word document so that the cover letter is created in Word, the fields from Access are automatically filled into the Word document. The query could be anywhere from 0-5000 names, one cover letter per name. AND to this cover letter for each applicant, there has to be attached a two page document. How in the world can...
0
2455
crystal2005
by: crystal2005 | last post by:
Hi, I am having trouble with some complex SQL queries. I’ve got winestore database, taken from Web Database Application with PHP and MySQL book. And some question about queries as the following 1. The wine name, grape variety, year, winery, and region 2. The minimum cost of wine in the inventory 3. The number of bottles available at the minimum price 4. The total number of bottles available at any price 5. The total number of unique...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10173
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4070
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 we have to send another system

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.