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

MS Access - Write to Table Immediately After Changing Value in Form
Unbind Access Project from source control
DAO access recordset not updating
No values given for one or more required parameters error only on some Windows 7 machines
In Memory, Stand-Alone, Disconnected ADO Recordset
Record-Locking in Access 10
How to force access to begin a new record
How should I setup Shipping and Receiving tables for RDBMS?
Remove link for linked table in access
MSACCESS 2002 Linked Table Performance Really Slow
ms access 2010 update linked table with no primary key
Memo field value truncated to about 1000 characters when inserted from a .net typed dataset
Access (.MDB) deployment issue - Windows 7 - Installation with admin user?
MS Access 2007 popup form refuses to display/not accessible in design mode (but present in list of forms)
Count email type per customer id
Access Row Data to Columns Based Off ID

Categories

HOME
webpack
c#-4.0
mediawiki
plone
angular-material
relative-path
iterator
hashmap
sd-card
android-4.4-kitkat
filtering
jsrender
ios-charts
virtualization
basic
python-unittest
n-gram
usergrid
phaser
seaborn
reactive-cocoa
http-status-code-504
visual-composer
plunker
orleans
accessor
brunch
traffic
ping
assistant
elasticsearch-net
objectanimator
quote
bpel
nat
sql-server-2012-express
pim
framemaker
ios5
overlap
adobe-premiere
espeak
vapor
impersonation
document.write
trim
dism
eclipse-scout
sql-server-agent
gulp-sourcemaps
g-code
elmah
node-gyp
isbn
checkboxlist
wptoolkit
auto-update
multipeer-connectivity
pnotify
rdfs
mu
git-diff
aurelia-validation
font-size
ifs
gnome-shell-extensions
topbeat
google-feed-api
impresspages
markojs
sigabrt
testng-dataprovider
apachebench
livequery
freelancer.com-api
iad
rtbkit
citrus-pay
muse
ios9.1
mono-embedding
p2
geonetwork
dia
tween
pick
winddk
cctv
titanium-modules
preferences
code-access-security
terminfo
contenttype
p4java
xceed-datagrid
opcache
ril
shellexecute
spring-validator
jelly
gil
mt
gdata-api
dsn
netdna-api
pydot
deobfuscation
blackberry-playbook
xmlspy
table-footer
actionview
propagation
dbal
nsviewanimation
asp.net-profiles
castle-monorail
web-architecture
firefox4
kdbg
xetex
scripting-languages
w3wp

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