Solved

Query only takes a little over 1000 characters

Posted on 2013-06-29
15
257 Views
Last Modified: 2013-07-08
I have a form that uses text boxes with code and a query in the form.

This was easier for me since Im not good at making complex calculations in query's.

The problem I had before was using the IIF statment with Between AND. Which I thank all the expert for there help and time.

Now I have come into a delima.

My query is over 1000 characters!! It was suggested that I use a Function. Which Im not familar with. And dont know how to incorparate it with how I have the form done now.

Help experts!

Please talk to me as simple as you can so that I can get it. Enclosed is the form that has the query in the form that calculates, and the summary with text boxes that have calculations in it also.

Again thanks for time and help!!!!!
HelpWithQuery--2-.zip
0
Comment
Question by:gigifarrow
  • 7
  • 6
  • 2
15 Comments
 
LVL 26

Expert Comment

by:jerryb30
Comment Utility
Is it working for you?
I don't think 1000 characters or even 2000 is going to hinder you, except that it makes it harder to make changes, find errors in typing the SQL.
It looks like you went away from the BETWEEN/AND statement in the query, and are expecting a range to be determined using the '-'.
So,  IIf([Production]=343-346
evaluates to Iff(production = -3
and so on.
Am i reading this correctly?
0
 

Author Comment

by:gigifarrow
Comment Utility
No I changed it to Between and just hadnt changed it here becsuse using - doesnt work
0
 
LVL 26

Expert Comment

by:jerryb30
Comment Utility
Well, need to see what you are using.
Also, does Between/And work? If not, what happens?
What do you want?
0
 

Author Comment

by:gigifarrow
Comment Utility
I need to add another iif statement because there are three different criterias but it goes over 1000 . So I  dont know what to do now
0
 

Author Comment

by:gigifarrow
Comment Utility
I have text with code. In the form using all queries dont know how to dobanything else
0
 
LVL 6

Assisted Solution

by:limweizhong
limweizhong earned 250 total points
Comment Utility
Non-intrusive:
1. Remove all the spaces after the commas.
2. Remove double spaces (I see one).
3. Remove all "F." and "[F]!", and "AS F"
4. Remove all unnecessary square brackets like "[Induction]".
5. Remove the extra "(" and ")" around the "Abs" calls.

Intrusive:
1. Remove "+Provision*0" and the like, since they contribute nothing.
2. Use the distributive rule of multiplication over addition to factor out the multiple "*10"s.
3. Replace "/100)*100" with ")" because "Abs" just removes the sign. Except that I think "Abs" is supposed to be "Int".
0
 
LVL 26

Expert Comment

by:jerryb30
Comment Utility
OK, I see now. 1024 characters for a query field definition is the limit.
Barring some previously offered suggestions (function, table of [Product] values), I think the BETWEEN/AND conditions might be separated from the calculations, in a true/false field. Although it might be better to make the separate table of products which get certain calculations, since those products might change over time. I'll look.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 26

Expert Comment

by:jerryb30
Comment Utility
off topic:  Remember NIE in 2011?
0
 
LVL 26

Expert Comment

by:jerryb30
Comment Utility
back on topic:
Couple of questions: Your current formula provides only 2 conditions, [product] number is a set list of values, or it is not. Then a different formula is provided for each condition. Will there be other possible percentage formulas for other [product] values?
Can you add a field or so to the root table, indicating which formula is to be used?
0
 
LVL 26

Expert Comment

by:jerryb30
Comment Utility
Correction: [Production] vs [Product]
If you add this to your query in design view-
calc1:([f].[production] Between 343 And 536) And [f].[production] Not In (375,376,377,378,381,382,383,384,385,386,387,388,389,390,404,408,411,423,429,430,431,465,466,468,469,470,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523)
and edit [Percentages] to read-
Percentages: IIf([calc1],(Abs(([F]![Induction]*6+[F]![TearDown]*10+[F]![Provision]*10+[F]![AssemblyA]*10+[F]![AsemblyB]*10+[F]![AssemblyC]*10+[F]![AssemblyD]*10+[F]![AssemblyE]*10+[F]![RoadTest]*4+[F]![QC]*10+[F]![OutDuction]*10)/100)*100),(Abs(([F]![Induction]*5+[F]![TearDown]*10+[F]![Provision]*0+[F]![AssemblyA]*20+[F]![AsemblyB]*0+[F]![AssemblyC]*0+[F]![AssemblyD]*20+[F]![AssemblyE]*25+[F]![RoadTest]*0+[F]![QC]*10+[F]![OutDuction]*10)/100)*100))

You should be way under your character limit for a query cell definition.

However, classifying the calculation to be used for a [Production] number in the root table is a better idea.
0
 
LVL 6

Expert Comment

by:limweizhong
Comment Utility
If it is a character limit for a query cell definition, I don't see why it even exceeds in the first place, even when you use the Between... And operator. After I converted it, I got 844 characters, and the query seems to give no error.

Percentages: IIf([Production] Between 343 And 346 Or [Production] Between 347 And 374 Or [Production] Between 379 And 380 Or [Production] Between 391 And 403 Or [Production] Between 405 And 407 Or [Production] Between 409 And 410 Or [Production] Between 412 And 422 Or [Production] Between 424 And 428 Or [Production] Between 432 And 464 Or [Production]=467 Or [Production] Between 471 And 507 Or [Production] Between 524 And 536,(Abs(([F]![Induction]*6+[F]![TearDown]*10+[F]![Provision]*10+[F]![AssemblyA]*10+[F]![AsemblyB]*10+[F]![AssemblyC]*10+[F]![AssemblyD]*10+[F]![AssemblyE]*10+[F]![RoadTest]*4+[F]![QC]*10+[F]![OutDuction]*10)/100)*100),(Abs(([F]![Induction]*5+[F]![TearDown]*10+[F]![Provision]*0+[F]![AssemblyA]*20+[F]![AsemblyB]*0+[F]![AssemblyC]*0+[F]![AssemblyD]*20+[F]![AssemblyE]*25+[F]![RoadTest]*0+[F]![QC]*10+[F]![OutDuction]*10)/100)*100))

Open in new window

0
 

Author Comment

by:gigifarrow
Comment Utility
I hadnt put the third criteria on because ikept getting  error message. It will be anther field as sbove with dlight different numbers.


can I really tske out this "(F)"
0
 
LVL 26

Accepted Solution

by:
jerryb30 earned 250 total points
Comment Utility
As long as you are only using one table in the query, yes, you may. As well as the alias 'as F'.
However, if you edit the query in design view, it will probably put the table name (or alias)  preceding the field name.
0
 

Author Comment

by:gigifarrow
Comment Utility
Wow I will try that!  Thst might be the answer I I whant to thank all og the experts for your time I eill back as soon as I try thid
0
 

Author Comment

by:gigifarrow
Comment Utility
Thank you for all the advice. I did take out the [F]![    ] . and then I put the extra criteria and it was still too  much. So I guess I need another alternative.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now