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

Where is the Form/Report `Menu` event (that relates to OnMenu) defined in Access?
Access VBA DLookup: Syntax error (missing operator) in query expression
MS Access - Speed Issue
MS Access 2016 - Updating Multiple Tables
Concatenated numbers stuck in scientific notation MS Access
ms access for each field
in access how to draw tables on Report and then export it on word
Automatically adding ID number from different table to new entries?
Access VBA Outlook MAPI- Prevent Record Update if email is not sent
data type mismatch error in criteria expression-ms access
Access Main Form 'Enter Parameter Value'
How to get a combobox2 to display records only relating to the selection made in combobox1?
Ms Access: Running an update query
Access Query that brings up decimal amounts
Access 2016 Processes not being killed during Automation but same works for Access 2013/10/07
Unable to use Multivalue field in an exsting Access form

Categories

HOME
testing
osgi
debugging
isabelle
mediawiki
path-finding
fft
grep
xmpp
react-redux
sql-server-2016
baqend
podio
metatrader4
after-effects
conemu
css-animations
nhapi
nouislider
ghost4j
picasso
bower-install
event-driven
email-templates
dynamic-reports
hibernate-tools
theming
rails-routing
domain-model
git-diff
crypt
r-forge
namecoin
pearson
cubes
gridpane
elements
mathematica-frontend
etsy
clang-static-analyzer
lua-5.1
ready-api
bluegiga
asp.net5
cloudbees
hsv
ora-00900
tmuxinator
twirl
createprocessasuser
vstest.console.exe
web-controls
key-management
sorl-thumbnail
article
system.net.webexception
transcoding
mcts
industrial
gridfs
tidy
buster.js
frameset
uiviewanimation-curve
oncheckedchanged
gallio
user-friendly
compiler-specific
sector

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