Results 1 to 4 of 4
  1. #1
    tdob12 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    4

    WHERE statement too long, any alternatives/options to shorten?

    Hi all -

    In this split form I am trying to filter records based off of user input information in the seven text boxes.

    The WHERE clause I am trying to write is too long (max is 255 characters). Any alternatives ways to go about this or methods to shorten the WHERE clause? I have already shortened the text box names and form names.

    Currently it is split into two like this:
    "Search" button: [Food] Like "*" & Forms![FSF]!FdSearch & "*"

    "Macros" button:

    [Protein (g)]>=[Forms]![FSF]![PMin] And [Protein (g)]<=[Forms]![FSF]![PMax] And [Carbo(g)]>=[Forms]![FSF]![CMin] And [Carbo(g)]<=[Forms]![FSF]![CMax] And [Fat (g)]>=[Forms]![FSF]![FMin] And [Fat (g)]<=[Forms]![FSF]![FMax]



    Thank you!Click image for larger version. 

Name:	fdsearch.jpg 
Views:	20 
Size:	88.1 KB 
ID:	29319

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Where are you doing this WHERE? In query object? I never use dynamic parameterized query objects. I use VBA to set filter criteria of forms and reports.

    I get 221 characters as the length of the criteria.

    Advise no spaces or punctuation/special characters (underscore only exception) in any names. Better would be FatG or Fat_g.

    You have space in [Fat (g)] and [Protein (g)] but not in [Carbo(g)]. Be consistent.

    Example:
    [Prot_g] BETWEEN [Forms]![FSF]![PMin] AND [Forms]![FSF]![PMax] And [Carb_g] BETWEEN [Forms]![FSF]![CMin] AND [Forms]![FSF]![CMax] And [Fat_g] BETWEEN [Forms]![FSF]![FMin] AND [Forms]![FSF]![FMax]

    That is 195 characters.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    tdob12 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    4
    Quote Originally Posted by June7 View Post
    Where are you doing this WHERE? In query object? I never use dynamic parameterized query objects. I use VBA to set filter criteria of forms and reports.

    I get 221 characters as the length of the criteria.

    Advise no spaces or punctuation/special characters (underscore only exception) in any names. Better would be FatG or Fat_g.

    You have space in [Fat (g)] and [Protein (g)] but not in [Carbo(g)]. Be consistent.

    Example:
    [Prot_g] BETWEEN [Forms]![FSF]![PMin] AND [Forms]![FSF]![PMax] And [Carb_g] BETWEEN [Forms]![FSF]![CMin] AND [Forms]![FSF]![CMax] And [Fat_g] BETWEEN [Forms]![FSF]![FMin] AND [Forms]![FSF]![FMax]

    That is 195 characters.
    Thank you. I am doing the where in a Macro

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    I don't use macros because of their limitations however in Junes revised naming, because spaces and none alpha numeric characters have been removed, you don't need the square brackets either which would save you another 42 characters. But it may be a macro forces you to have them.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 20
    Last Post: 06-08-2015, 08:05 PM
  2. Replies: 13
    Last Post: 06-04-2014, 10:44 AM
  3. Replies: 5
    Last Post: 04-20-2012, 03:54 PM
  4. Substitute for overly-long IIf statement?
    By Captain Database ...!! in forum Queries
    Replies: 14
    Last Post: 07-14-2011, 12:00 PM
  5. Using DSN alternatives with MYSQL
    By ajetrumpet in forum Access
    Replies: 2
    Last Post: 10-14-2010, 12:55 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums