473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Access Query too complex?

I have a query I am running that is taking form values and basically making sure that they are not null before including them in calculations to determine the amount of $$ a person should be reimbursed before travelling. I recently mad a couple of changes (removed a field) and now it works fine when I only have 2 days worth of reimbursement data, but when I go to 3 I get an error that it may be too complex and it can not be run. Can you all please look at this and give me a hand? Thanks!

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT TravelData.Name, TravelData.Purpose, TravelData.Depart_Time, TravelData.Return_Time, TravelData.Date, TravelData.Project, TravelData.From, TravelData.To, IIf(Nz([Mileage]),[Mileage],0) AS ExMileage, IIf(Nz([Lodging]),[Lodging],0) AS ExLodging, IIf(Nz([Perdiem]),[Perdiem],0) AS ExPerdiem, IIf(Nz([Bag_Tips]),[Bag_Tips],0) AS ExBag, IIf(Nz([Taxi]),[Taxi],0) AS ExTaxi, IIf(Nz([Parking]),[Parking],0) AS ExParking, IIf(Nz([Travel]),[Travel],0) AS ExTravel, IIf(Nz([Rental]),[Rental],0) AS ExRental, IIf(Nz([Gas]),[Gas],0) AS ExGas, IIf(Nz([Other1_Amt]),[Other1_Amt],0) AS ExOth1, IIf(Nz([Other2_Amt]),[Other2_Amt],0) AS ExOth2, CCur(RoundCC([Mileage]*0.445)) AS Auto_Expenses, CCur(IIf(Nz([Lodging]),[Lodging],0)+IIf(Nz([Perdiem]),[Perdiem],0)+IIf(Nz([Bag_Tips]),[Bag_Tips],0)+IIf(Nz([Taxi]),[Taxi],0)+IIf(Nz([Parking]),[Parking],0)+IIf(Nz([Travel]),[Travel],0)+IIf(Nz([Rental]),[Rental],0)+IIf(Nz([Gas]),[Gas],0)+IIf(Nz([Other1_Amt]),[Other1_Amt],0)+IIf(Nz([Other2_Amt]),[Other2_Amt],0)+IIf(Nz([Auto_Expenses]),[Auto_Expenses],0)) AS Total, CCur(IIf(Nz([Lodging]),[Lodging],0)+IIf(Nz([Perdiem]),[Perdiem],0)+IIf(Nz([Bag_Tips]),[Bag_Tips],0)+IIf(Nz([Taxi]),[Taxi],0)+IIf(Nz([Parking]),[Parking],0)+IIf(Nz([Travel]),[Travel],0)+IIf(Nz([Rental]),[Rental],0)+IIf(Nz([Gas]),[Gas],0)+IIf(Nz([Other1_Amt]),[Other1_Amt],0)+IIf(Nz([Other2_Amt]),[Other2_Amt],0)+IIf(Nz([Auto_Expenses]),[Auto_Expenses],0)) AS 5300TOT, TravelData.Comments, TravelData.Other1, TravelData.Other2, TravelData.Lodging, TravelData.Perdiem, TravelData.Bag_Tips, TravelData.Taxi, TravelData.Parking, TravelData.Travel, TravelData.Rental, TravelData.Gas, TravelData.Other1_Amt, TravelData.Other2_Amt, IIf(Nz([Auto_Expenses]),[Auto_Expenses],0) AS ExAuto
  3. FROM TravelData 
  4. WHERE (((TravelData.Name)=[forms]![frmMainMenu]![txtName]))
  5. GROUP BY TravelData.Name, TravelData.Purpose, TravelData.Depart_Time, TravelData.Return_Time, TravelData.Date, TravelData.Project, TravelData.From, TravelData.To, IIf(Nz([Mileage]),[Mileage],0), IIf(Nz([Lodging]),[Lodging],0), IIf(Nz([Perdiem]),[Perdiem],0), IIf(Nz([Bag_Tips]),[Bag_Tips],0), IIf(Nz([Taxi]),[Taxi],0), IIf(Nz([Parking]),[Parking],0), IIf(Nz([Travel]),[Travel],0), IIf(Nz([Rental]),[Rental],0), IIf(Nz([Gas]),[Gas],0), IIf(Nz([Other1_Amt]),[Other1_Amt],0), IIf(Nz([Other2_Amt]),[Other2_Amt],0), CCur(RoundCC([Mileage]*0.445)), CCur(IIf(Nz([Lodging]),[Lodging],0)+IIf(Nz([Perdiem]),[Perdiem],0)+IIf(Nz([Bag_Tips]),[Bag_Tips],0)+IIf(Nz([Taxi]),[Taxi],0)+IIf(Nz([Parking]),[Parking],0)+IIf(Nz([Travel]),[Travel],0)+IIf(Nz([Rental]),[Rental],0)+IIf(Nz([Gas]),[Gas],0)+IIf(Nz([Other1_Amt]),[Other1_Amt],0)+IIf(Nz([Other2_Amt]),[Other2_Amt],0)+IIf(Nz([Auto_Expenses]),[Auto_Expenses],0)), CCur(IIf(Nz([Lodging]),[Lodging],0)+IIf(Nz([Perdiem]),[Perdiem],0)+IIf(Nz([Bag_Tips]),[Bag_Tips],0)+IIf(Nz([Taxi]),[Taxi],0)+IIf(Nz([Parking]),[Parking],0)+IIf(Nz([Travel]),[Travel],0)+IIf(Nz([Rental]),[Rental],0)+IIf(Nz([Gas]),[Gas],0)+IIf(Nz([Other1_Amt]),[Other1_Amt],0)+IIf(Nz([Other2_Amt]),[Other2_Amt],0)+IIf(Nz([Auto_Expenses]),[Auto_Expenses],0)), TravelData.Comments, TravelData.Other1, TravelData.Other2, TravelData.Lodging, TravelData.Perdiem, TravelData.Bag_Tips, TravelData.Taxi, TravelData.Parking, TravelData.Travel, TravelData.Rental, TravelData.Gas, TravelData.Other1_Amt, TravelData.Other2_Amt, IIf(Nz([Auto_Expenses]),[Auto_Expenses],0)
  6. ORDER BY TravelData.Date;
  7.  
NOTE: RoundCC is a function I wrote to round my currency calculations based on mileage. Even when I told Access it was a currency field it still kept more than 2 digits. It also did not round correctly (44.555 rounded to 44.55 instead of 44.56). so roundCC calls that function.
Jun 13 '06 #1
1 3148
PEB
1,418 Expert 1GB
There is a lot of IIF!!! But maybe they are necessery!!!

So I think that it's better that in your Where clause you don't have as parameter a Form parameter, its's better to place there a String!

Also it's very important to make firstly an ordinary query without groub by clause!!! If it is working You have a chance!

Then You can create an agregate query using the ready results!
If the second query gives an error, so you can save the result of the first query in a temporary table and then do an agregate query on a table! :)
Sep 3 '06 #2

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

Similar topics

6
by: Jegger | last post by:
Hello! We have following situation; network with 100 users, aplication developed in Access, user DB deployed on SQL Server. Is it better to create query inside aplication (with code) and then...
10
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...
27
by: SQL Learner | last post by:
Hi all, I have an Access db with two large tables - 3,100,000 (tblA) and 7,000 (tblB) records. I created a select query using Inner Join by partial matching two fields (X from tblA and Y from...
8
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...
1
by: Randy Volkart | last post by:
I'm trying to fix a glitch in a complex access database, and have a fairly complex problem... unless there's some obscure easy fix I don't know being fairly new with Access. Basically, the area...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...

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.