Workaround to limit in space in the criteria box in query design view?

(As quick background, I inherited a db in its most raw and basic state.  There is very little automation in it, i.e., only a handful; of forms.  There wasn't even a switchboard until I created one!  Phew!)

I ran into a limitation today.  I was required to filter out about 44 companies from our database in one of the queries.  I used this type of syntax below (I'll use some electronics companies here as examples):

Not like "*philips*" AND not like "*Samsung*" AND not like "*Sony*" AND ...

and so on down the long line.

I ran out of space.  I was typing along and then hit a wall and couldn't enter any more criteria text.  I haven't developed so intensely in Access since 2005 and this isn't something I've run into before.  Because I ran out of room, I ended up having to give a miss to the last 5 companies on the list which meant I had to later go to the Excel exported output sheet and delete all corresponding records which turned out to be about 80 rows in total.

Until things change, since we have to use this method for now, what other options do we have when filtering in the query to work around the limit in text that can be entered?  Are we truly limited by a set number of characters in one sole criteria box or is there something else that can be done, as well??

p.s., I consider myself a beginner-intermediate Access developer, not a complete novice but not very advanced either, so hoping there's something that I can manage to do within the query until we fix the db probably some months down the road.

Thanks!



p.s., Eventually I'd like to build something that the users can perhaps use pulldown boxes (or whatever) to draw upon the names already in the db and that way I and other users will be able to filter out companies using a very easy method without all the typing and real possible user errors that can happen with the method I had to use today.

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.

To what kind of field does this criterion apply? Is it a big messy text field with the company name embedded in it (inconsistantly no doubt, e.g. Philips Inc., Philips AG, Philips Electronics), or with multiple company names in the field?

 

What you may be able to do is set up a (permanent or temporary) Exclusions table with one record per company to exclude; you could then use a query like

 

SELECT <whatever>
FROM mytable LEFT JOIN Exclusions
ON mytable.myfield LIKE "*" & Exclusions.CompanyName & "*"

WHERE Exclusions.CompanyName IS NULL

AND <any other criteria>

 

But certainly, a normalized design with a numeric CompanyID is going to be a lot easier to manage both for you and your users.

 

 

John W. Vinson/MVP

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Eventually I'd like to build something that the users can perhaps use pulldown boxes (or whatever) to draw upon the names already in the db and that way I and other users will be able to filter out companies using a very easy method without all the typing and real possible user errors that can happen with the method I had to use today.

Take a look at the file MultiSelect.zip in my public databases folder at:

https://skydrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

In the Click event procedure of the frmEmployeeDlg form which is opened from the 'Filter Report by WhereCondition Argument' button on the opening form, change the string expression for the criteria to exclude rather than include the selected employees from:

        strCriteria = "EmployeeID In(" & strEmployeeIDList & ")"
to:
        strCriteria = "EmployeeID Not In(" & strEmployeeIDList & ")"

The report will then report the employees not selected.

Note that when building the value list for the In operator when looping through the ItemsSelected collection earlier in the code in the same procedure you will need to delimit each value with quotes characters if the values are of text data type, rather than a number data type as in my example.

_____________________
Ken Sheridan,
Newport, Shropshire, England

"Don't write it down until you understand it!" - Richard Feynman

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

To what kind of field does this criterion apply? Is it a big messy text field with the company name embedded in it (inconsistantly no doubt, e.g. Philips Inc., Philips AG, Philips Electronics), or with multiple company names in the field? 

Well, it's not quite so bad.  It's a large text field with one company per record but, yes, your example is spot on - i.e., Philips Inc., Philips AG, Philips Electronics, that sort of thing.  And then there are multiple members per each company ... so quite a task to filter out different sets of companies twice a week!

What you may be able to do is set up a (permanent or temporary) Exclusions table with one record per company to exclude; you could then use a query like

 

SELECT <whatever>

FROM mytable LEFT JOIN Exclusions

ON mytable.myfield LIKE "*" & Exclusions.CompanyName & "*"

WHERE Exclusions.CompanyName IS NULL

AND <any other criteria>


But certainly, a normalized design with a numeric CompanyID is going to be a lot easier to manage both for you and your users.


Youch.  I hate to say it but this seems beyond me at this point.  A whole new table with a numeric CompanyID for Access's use (behind-the-scenes??) sounds great but I can't picture all the details of what to do to accomplish this.  And the time involved ... <sigh>.  My boss will definitely not go for any sort of re-structuring at this time.  That's part of the problem, needing to work with what I have at this time.

----------------------
Bottom line, until such time as I learn enough to fix some of the db's design flaws or I convince my boss to bring in a developer to do that (not sure how well that will go across ...), is there absolutely _no_ workaround to the maximum character limitation in the query criteria box??????
----------------------

I've found out, as I mentioned above, that I need to do 2 output files a week from the db and they'll involve different exclusions for different reasons each and every time.  I can figure out a way to create the exclusions outside of Access.  A simple gui using a scripting program I know very well will streamline and speed up that part of the query - getting the exclusions into the criteria field - but having to manually edit the data output in Excel to finish filtering out the relevant companies adds too much extra time to the process; disheartening esp. when knowing that it takes Access milliseconds to do!

Pls advise.



----------------------
p.s., what is the maximum number of characters the criteria field can handle in a query, anyone know?
----------------------

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Eventually I'd like to build something that the users can perhaps use pulldown boxes (or whatever) to draw upon the names already in the db and that way I and other users will be able to filter out companies using a very easy method without all the typing and real possible user errors that can happen with the method I had to use today.

Take a look at the file MultiSelect.zip in my public databases folder at:

https://skydrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

Thank you!  I'll definitely take a look at that.  Examples are always easier to deal with, aren't they?

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

The only alternative I can suggest is to switch to SQL View and tpe your string directly into there.
Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Microsoft Access MVP since 2007

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

The only alternative I can suggest is to switch to SQL View and tpe your string directly into there.
I've never gone into that view, so that was pretty neat seeing how that works.

The syntax adds some extra wording to accommodate the table name.  However, no worries.  Until such time as my boss approves having a proper and bona-fide developer come in to help with this db (if at all), I've got an external gui written in a scripting language where I just type in the company names to filter out and will get a text string that can then be copied to the clipboard with the push of a button.  Then that can just be dumped into the criteria box.  That'll save a lot of typing time and will help eliminate user error during the typing process.  If there are any missing companies in the filter due to the maximum-character limitation in the criteria field, I'll just add manually to the SQL view.  Will still save loads of time since the exported data in the Excel sheet will be ready to use with no editing needed after the fact.

To that end, my script apparently can have a set ceiling on the maximum number of characters entered.  It would be nice to know what is the maximum allowable (including spaces between words, I imagine) in the criteria box in any query design view - does anyone know?

Thx much!!

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

If you have a file (or a spreadsheet, or best of all a Table) of the names you want to exclude, you can create a Query to do so. Note that this Query JUST would use a JOIN - no criteria at all! Did you try the Exclusions table I posted upthread?

 

I do have one big red warning though. Any time you have uncontrolled vocabulary and wildcards you WILL - not may, but WILL - get erroneous results. Suppose you wanted to exclude a company named API with a criterion of

 

NOT LIKE "*API*"

 

This criterion will also exclude "Apiculture" and "Rapid Graphics" and "Capitol Press" and any other name containing that text string!

 

You can get around this by making the criterion a lot more complex:

 

NOT LIKE "Api *" AND Not Like "* API *" AND NOT LIKE "* API"

 

to set the name off with blanks and allow for it to be the first substring ("API Limited"), embedded with flanking blanks ("Boise API Inc.") or at the end of the string preceded by a blank... but this isn't perfect (there might be other punctuation, not just blanks); and the query will be inefficient and a pain to maintain!

 

John W. Vinson/MVP

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I do have one big red warning though. Any time you have uncontrolled vocabulary and wildcards you WILL - not may, but WILL - get erroneous results. Suppose you wanted to exclude a company named API with a criterion of

 

NOT LIKE "*API*"

 

This criterion will also exclude "Apiculture" and "Rapid Graphics" and "Capitol Press" and any other name containing that text string! 

Yes, thank you - good to point that out as other people use these boards as research, like I do.  Good to know the pitfalls.

I did run into that when I first did the exclusions when I ran across a completely different company than the one that I needed to exclude and it got dumped in <g>.  With 18,000+ records, it's bound to be an issue but I'm confident that once I learn the data better, I'll be able to keep that to a minimum.  Fortunately, when in doubt, we can minimize the errors but putting in more specific characters to get the results we need like when I knew we had subsidiaries that needed to remain even as the main were to be excluded (since the parent company was a sponsor and the subsidiary was not - needed to exclude the sponsor).

Thank you!

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

If you have a file (or a spreadsheet, or best of all a Table) of the names you want to exclude, you can create a Query to do so. Note that this Query JUST would use a JOIN - no criteria at all! Did you try the Exclusions table I posted upthread?


<sheepish grin> Um, sorry, no.  As I posted on Jun.10, since some of the things I couldn't wrap my brain around yet, I'm tabling that idea for a bit.  I have no extra time at work to do this and I'm already putting in 1-2 hours daily of overtime to clear up the backlog my predecessor left since he left without notice and things languished until I was brought on board.  Soon I'll stay after work to try that idea out and hopefully I'll be able to make heads or tails of it then when I'm actually working on it (I don't have A10 at home).

Thank you!

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

It would be nice to know what is the maximum allowable (including spaces between words, I imagine) in the criteria box in any query design view - does anyone know?
Can anyone tell me the maximum number characters the criteria box allows in a query design view?  I've continued to google but haven't found an answer.  The answers go off on all sorts of tangents with nothing revealing the answer to this specifically  ... <g>.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.

 
 

Question Info


Last updated October 5, 2021 Views 3,411 Applies to: