ms-access


Microsoft Access Query is too complex to run - IF formula


I have a query in Access Database and when I try to run it, I get an error message "query is too complex to run." Runtime error 3360." The problem is with one formula / programming logic, see below:
Previously the formula was the below - and it worked.
IIf([BegTaxBasis]=0 And [Contribution]+[Distribution]=0,
0,
IIf([BegTaxBasis]=0 And [TaxIncSubTotal]=0,
-[Distribution],
IIf([Distribution]=0,
0,
IIf([TBBLL]+[Recourse]+[QualifiedNonrecourse]+[NonRecourse]<[Distribution],
-[Distribution],
0))))
Then I updated it to, see below:
IIf([BegTaxBasis]=0 And [Contribution]+[Distribution]=0,
0,
IIf([BegTaxBasis]=0 And [TaxIncSubTotal]=0,
-[Distribution],
IIf([Distribution]=0,
0,
IIf([TBBLL]>0,
0,
IIf([TBBLL]+[Recourse]+[QualifiedNonrecourse]+[NonRecourse]<[Distribution],
-[Distribution],
IIf([TBBLL]+[Recourse]+[QualifiedNonrecourse]+[NonRecourse]>[Distribution] And [TBBLL]+[Recourse]+[QualifiedNonrecourse]+[NonRecourse]<0 And [TaxIncSubTotal]<0,
[TBBLL]+[Recourse]+[QualifiedNonrecourse]+[NonRecourse]-[TaxIncSubTotal],
[TBBLL]+[Recourse]+[QualifiedNonrecourse]+[NonRecourse])))))
And now the query wont run, any help is much appreciated, thanks!
You could try assigning intermediate values to a separate field or fields, then reference such fields in the final expression. This will only work for certain queries and SQL clauses, but you didn't give a context for your formula so I can't comment more on your particular code. These type of intermediate field values cannot be referenced in JOIN, ORDER BY or WHERE clauses--only in other SELECT fields. The order of the fields is important... the field must be defined before referencing it later in the SQL statement.
This facilitates re-use of duplicate expression, e.g. [TBBLL]+[Recourse]+[QualifiedNonrecourse]+[NonRecourse], so it can shorten the overall query.
For example:
SELECT ([TBBLL]+[Recourse]+[QualifiedNonrecourse]+[NonRecourse]>[Distribution]
And [TBBLL]+[Recourse]+[QualifiedNonrecourse]+[NonRecourse]<0
And [TaxIncSubTotal]<0) As Condition1,
([TBBLL]+[Recourse]+[QualifiedNonrecourse]+[NonRecourse]-[TaxIncSubTotal]) As TrueValue1,
([TBBLL]+[Recourse]+[QualifiedNonrecourse]+[NonRecourse]) As FalseValue1,
Iif([Condition1],[TrueValue1],[FalseValue1]) As FalseValue2,
...
[Some final calculation using previous fields] As FinalValue
A similar technique is to calculate some values in another saved or embedded query then join to that query and reference the partial calculations for the final expression. This technique can overcome the limitations of defining fields in the same select query. For instance, this would allow using intermediate calculated values in a join expression, whereas the first technique would not allow that. Using a series of saved, joined queries would circumvent single-query length limitations as mentioned by June7.

Related Links

Is ACE/Jet's IN operator or CHECK constraint 'broken'?
Form.CurrentRecord=1 and Form.RecordSet.Absoluteposition=-1
email using Access and VBA without MAPI
MS Access Properties
Will Access support 35- 40 users writing to a Access database
Trying to limit input on a field
Sorting by month in MS Access
How to add a menu item to the default right click context menu
ASP Access Database web site on Windows 2008 Server running IIS 7
How to populate field descriptions in MS Access
Version control for VBA file
Mystery HAVING clause
MS Access 2003 - Sparkline Graphs in Microsoft Access
How to extract the schema of an Access (.mdb) database?
Using loop in a Access Query
Access 2007 Empty Query Quirk

Categories

HOME
pandas
drivers
android-4.4-kitkat
adb
setup-deployment
infragistics
google-project-tango
onelogin
qore
pheatmap
applepay
node-pdfkit
collectd
google-cloud-ml
decimal
libtiff
django-admin
serilog
pythonanywhere
samoa
clickonce
mps
rundeck
opennlp
numerical-methods
pepper
windows-error-reporting
strncpy
dbclient
google-cloud-nl
delicious-api
yadcf
google-cloud-endpoints-v2
scorm2004
code-contracts
wixsharp
android-browser
hilbert-curve
uft-api
document.write
temporary-files
http-live-streaming
nxlog
eclipse-gef
segment
qcombobox
skeleton-css-boilerplate
angular-resource
menuitem
fault
network-flow
hibernate-tools
apache-fop
hendrix
fancybox-2
git-diff
sqlbulkcopy
memory-alignment
sonarlint-vs
mediaelement
medium.com
google-web-starter-kit
ptrace
tmuxinator
ionic
angular-local-storage
cctv
wordpress-theme-customize
markers
wp-query
doskey
bulkloader
eclipse-memory-analyzer
smtp-auth
frameset
php-parser
psi
invite
locationlistener
servicehost
sortable-tables
ext3
thunderbird-lightning
microsoft-virtualization
avatar
msdev
wsdl.exe

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App