Results 1 to 10 of 10
  1. #1
    lbaccess101 is offline Novice
    Windows XP Access 2016
    Join Date
    May 2017
    Posts
    13

    newbie confused


    I have a query that works but I don't understand it. I have multiple criteria with "OR is null" written into each originally, then when I have and re-open, access creates new fields the query for those "Is Null" fields. Okay fine, but so then I get 10+ rows or criteria...and thus a very long sql statement. Smarter way of doing this or am I pushing the query limit? super lost....
    Click image for larger version. 

Name:	qrycomplex.jpg 
Views:	13 
Size:	117.2 KB 
ID:	29758

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Start again from the beginning. Add one line of criteria, and one field at a time. Not sure why you are using "Like", that means that there are wild cards (*, ?, etc) in the criteria string, I can't see them so maybe they are at the end. If you remove it there won't be so much to look at. Then change the form fields to Nz(Forms!.....) then you won't have to worry about when the form field is empty.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Also, it is usually helpful to readers -and to you -to describe what you are trying to do in plain, simple English so we get some context for the issue. In this case it is a question of using the query designer,and your use of "LIKE" may be the real issue.

    Welcome and good luck.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    What you see is result of using OR operator and is normal.

    As aytee111 notes, using LIKE operator is only meaningful if also using wildcard.

    Why do you have IIf() in some of the parameters?

    So if you do have the wildcard character concatenated in the parameters, try using AND operator instead of OR. Switch to SQL View to quickly edit the WHERE clause so there is only one set of the parameters with AND operator between them and then switch back to Design View.

    I never use dynamic parameterized queries. I prefer to use VBA code to construct criteria. Review http://allenbrowne.com/ser-62.html
    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.

  5. #5
    lbaccess101 is offline Novice
    Windows XP Access 2016
    Join Date
    May 2017
    Posts
    13
    That is all super helpful people thank you! <3 I must be doing something roundabout/unnecessary. I have several comboxes to narrow down criteria (from a form) and in a simpler query, the Like was working but perhaps I need better understanding of underlying query building....okay thanks! be back again I'm sure.

  6. #6
    lbaccess101 is offline Novice
    Windows XP Access 2016
    Join Date
    May 2017
    Posts
    13
    When you say change form fields to Nz I'm not sure where you mean. In the actual form or in the query criteria build statement? I have a radio button where it's either option 1, option 2 or if I don't select either I want to view all records. ....

  7. #7
    lbaccess101 is offline Novice
    Windows XP Access 2016
    Join Date
    May 2017
    Posts
    13
    Quote Originally Posted by June7 View Post
    What you see is result of using OR operator and is normal.

    As aytee111 notes, using LIKE operator is only meaningful if also using wildcard.

    Why do you have IIf() in some of the parameters?

    So if you do have the wildcard character concatenated in the parameters, try using AND operator instead of OR. Switch to SQL View to quickly edit the WHERE clause so there is only one set of the parameters with AND operator between them and then switch back to Design View.

    I never use dynamic parameterized queries. I prefer to use VBA code to construct criteria. Review http://allenbrowne.com/ser-62.html
    I see Allene's 2 methods. His query is also has crazy long sql...so maybe I'm not that off. Okay I've been looking up the VBA method, seems it's more reliable for lengthy queries. Where do you start though? Do you build it as a sql statement after hitting "create new query/query design?" or do you create a button and in the backend of a form from which you want to run a query and write this all out somehow there in visual basic editor?...clearly I'm lost, I've never done it that way. Any pointers where to start? thanks again all!

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Incorporate whatever works for you into your db.

    What exactly do you not understand about his examples? Did you download the database and explore?
    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.

  9. #9
    lbaccess101 is offline Novice
    Windows XP Access 2016
    Join Date
    May 2017
    Posts
    13
    Quote Originally Posted by June7 View Post
    Incorporate whatever works for you into your db.

    What exactly do you not understand about his examples? Did you download the database and explore?
    Well yes, the one reffered to there called "search 2000" . He has a form and then a query called "alternative method" so, it's a little confusing what is going into the creating of that filter form. Do you need both actual query and the manual code in vba he wrote out when you click on cmdfilter in design view?

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    The VBA approach does not use the 'alternative method' query, that's why it's called 'alternative method'.

    The VBA code constructs a filter criteria string and applies that string to the Filter property of form. Or use it in the WHERE CONDITION argument of OpenForm or OpenReport commands.

    If the 'alternative method' query is used then it would be the RecordSource of form being filtered and the VBA procedure building criteria string would not be used.
    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.

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

Similar Threads

  1. I am confused please help me
    By pedjvak in forum Forms
    Replies: 5
    Last Post: 04-20-2013, 02:13 AM
  2. very confused about relationships
    By devxweb in forum Access
    Replies: 3
    Last Post: 12-20-2012, 06:47 AM
  3. I am a bit confused by this one
    By wubbit in forum Access
    Replies: 7
    Last Post: 05-15-2012, 03:18 PM
  4. Confused!!!
    By mkc80 in forum Access
    Replies: 1
    Last Post: 05-11-2012, 04:39 PM
  5. Just Confused
    By BigCat in forum Access
    Replies: 1
    Last Post: 05-09-2011, 12:57 PM

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