Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
SQL Query Crashes Access
Dan Jackson 
            
4 years ago
Hi Yo,

What i'm trying to do
I set up a VERY basic calculator in access to calculate sum assured and premium increases every year for 5-50 years. Like a good boy, i'm performing the calculation in a query.

*Important Note*
I realise there are probably half a million better ways to do this, including doing it in excel but i'm killing two birds with one database - a need for a simple calculator and my need to learn access!

Setup
1 table with only 1 record - the current one (Data doesn't need to be stored, only calculated) with columns for "Sum Assured", "Premium", "Term", "Percent".
1 query containing all remaining fields which are calculated.
1 form

Problem
Being lazy, I set up the basics in query design view, then copied the SQL to word and manually c&p'ed the text and editing etc to create the full query. However, upon running this, Access crashes every time.

Question
Is there a limit on queries or have I done something hideously wrong (like me)?

SQL below, drum roll please!


sql
SELECT IncreasingCalculatorT.SumAssured, IncreasingCalculatorT.Premium, IncreasingCalculatorT.Term, IncreasingCalculatorT.Percent, [SumAssured]*[Percent]+[SumAssured] AS SAYear1, [SAYear1]*[Percent]+[SAYear1] AS SAYear2, [SAYear2]*[Percent]+[SAYear2] AS SAYear3, [SAYear3]*[Percent]+[SAYear3] AS SAYear4, [SAYear4]*[Percent]+[SAYear4] AS SAYear5, [SAYear5]*[Percent]+[SAYear5] AS SAYear6, [SAYear6]*[Percent]+[SAYear6] AS SAYear7, [SAYear7]*[Percent]+[SAYear7] AS SAYear8, [SAYear8]*[Percent]+[SAYear8] AS SAYear9, [SAYear9]*[Percent]+[SAYear9] AS SAYear10, [SumAssured]*[Percent]+[SumAssured] AS SAYear11, [SAYear11]*[Percent]+[SAYear11] AS SAYear12, [SAYear12]*[Percent]+[SAYear12] AS SAYear13, [SAYear13]*[Percent]+[SAYear13] AS SAYear14, [SAYear14]*[Percent]+[SAYear14] AS SAYear15, [SAYear15]*[Percent]+[SAYear15] AS SAYear16, [SAYear16]*[Percent]+[SAYear16] AS SAYear17, [SAYear17]*[Percent]+[SAYear17] AS SAYear18, [SAYear18]*[Percent]+[SAYear18] AS SAYear19, [SAYear19]*[Percent]+[SAYear19] AS SAYear20, [SAYear20]*[Percent]+[SAYear20] AS SAYear21, [SAYear21]*[Percent]+[SAYear21] AS SAYear22, [SAYear22]*[Percent]+[SAYear22] AS SAYear23, [SAYear23]*[Percent]+[SAYear23] AS SAYear24, [SAYear24]*[Percent]+[SAYear24] AS SAYear25, [SAYear25]*[Percent]+[SAYear25] AS SAYear26, [SAYear26]*[Percent]+[SAYear26] AS SAYear27, [SAYear27]*[Percent]+[SAYear27] AS SAYear28, [SAYear28]*[Percent]+[SAYear28] AS SAYear29, [SAYear29]*[Percent]+[SAYear29] AS SAYear30, [SAYear30]*[Percent]+[SAYear30] AS SAYear31, [SAYear31]*[Percent]+[SAYear31] AS SAYear32, [SAYear32]*[Percent]+[SAYear32] AS SAYear33, [SAYear33]*[Percent]+[SAYear33] AS SAYear34, [SAYear34]*[Percent]+[SAYear34] AS SAYear35, [SAYear35]*[Percent]+[SAYear35] AS SAYear36, [SAYear36]*[Percent]+[SAYear36] AS SAYear37, [SAYear37]*[Percent]+[SAYear37] AS SAYear38, [SAYear38]*[Percent]+[SAYear38] AS SAYear39, [SAYear39]*[Percent]+[SAYear39] AS SAYear40, [SAYear40]*[Percent]+[SAYear40] AS SAYear41, [SAYear41]*[Percent]+[SAYear41] AS SAYear42, [SAYear42]*[Percent]+[SAYear42] AS SAYear43, [SAYear43]*[Percent]+[SAYear43] AS SAYear44, [SAYear44]*[Percent]+[SAYear44] AS SAYear45, [SAYear45]*[Percent]+[SAYear45] AS SAYear46, [SAYear46]*[Percent]+[SAYear46] AS SAYear47, [SAYear47]*[Percent]+[SAYear47] AS SAYear48, [SAYear48]*[Percent]+[SAYear48] AS SAYear49, [SAYear49]*[Percent]+[SAYear49] AS SAYear50
FROM IncreasingCalculatorT;
Scott Axton  @Reply  
        
4 years ago
TLDR -  If this opens and works using the designer then the statement should work.
If it doesn't open then your edit(s) goofed something up.

Yes there is a limit:
MS Access Specifications

Number of characters in an SQL statement: 64,000 characters

NOTE: In queries, maximum values might be lower if the query includes multivalued lookup fields.
Scott Axton  @Reply  
        
4 years ago
FYI - DO NOT use MS Word to work with code.  Word inserts different characters (some invisible) that can / will goof you up.

Only use a pure text editor such as Note Pad - Included with Windows
or if you want more functionality check out Notepad++.
Free and I prefer it over Note Pad for a lot of things.
Dan Jackson OP  @Reply  
            
4 years ago
Hi Scott,

- TLDR
I tried to be descriptive as is constantly mentioned on the forum (I try to pay attention to requirements) and hoped that by separating into "What I'm trying to do", "Setup" etc.... would help readability.
With the greatest of respect, I can explain and not "treat you like clairvoyants" or i can keep to a simple, 1 or 2 line question. I tried to compromised by separating into sections but not sure where the sweetspot is?

- If this opens and works using the designer then the statement should work.
Yes, it opens in designer but doesn't run

- Yes there is a limit
Saw that page, The code complies to the best of my knowledge

- Number of characters in an SQL statement: 64,000 characters
Even with spaces, #Characters are 2388 - not even close

Cheers
Dan Jackson OP  @Reply  
            
4 years ago
FYI - DO NOT use MS Word to work with code.

This is great advice, thanks. I did copy the code into notepade, then back into Access as a troubleshooting step but no luck :(
Dan Jackson OP  @Reply  
            
4 years ago
I think i'm just hitting some kind of invisible barrier with the query complexity. I'll do some more research/ find another way around....
Scott Axton  @Reply  
        
4 years ago
Dan you did OK -
It's just I don't have the time right now to look at that statement in depth to see where you missed a space or comma or....

You are correct it is a fine line to provide enough information that is pertinent but not so much it clouds what you are doing.

You are under the 64K limit so I suspect that it is a case of using Word.

Dan Jackson OP  @Reply  
            
4 years ago
Awesome, thank you scott. I'm gonna take a break and come back. When i do, i'll try rewriting the code from scratch in notepad and psot result - don't waste your time. Many thanks
Scott Axton  @Reply  
        
4 years ago
You had the right idea using the Query Designer.  What I would do is just put the whole thing in there. You can copy and past there as well - just changing your year numbers and alias description.

The other thing that might be happening is there are to many calculations going on,  but that I doubt.  You can do some pretty wild stuff with queries.
Alex Hedley  @Reply  
           
4 years ago
Try it in VSCODE and use PoorMansTSQLFormatter and it might find some issues.
Kevin Robertson  @Reply  
          
4 years ago
Dan,

I just run through an example adding columns to the query one by one. This is what I got when I got to "SAYear14"
Looks like you may need to use multiple queries to get this to work.
Kevin Robertson  @Reply  
          
4 years ago

Richard Rost  @Reply  
          
4 years ago
Ouch. I got brain freeze just looking at that SQL. This should be set up the same way I do Loan Amortizations... not as multiple fields in a record, but as multiple records in a related table/subform.
Dan Jackson OP  @Reply  
            
4 years ago
Nice one, thanks Richard, I'll check it out!

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/2/2026 8:29:46 AM. PLT: 1s