Results 1 to 6 of 6
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Subform not having the right query results in group recordsource

    I have a subform with a group query as the record source



    I've put a like operator on one of the grouped fields with wildcards so the user can type text on the main form and have it filter the subform when that person requeries the subform.

    The field is AREA

    it is grouped
    Code:
    IIf(IsNull([forms]![frmStatistics]![txtAreasfilter1]),[tblareas]![Area],([tblAreas].[Area]) Like '*" & [forms]![frmStatistics]![txtAreasfilter1] &   "*')
    I don't know why it comes up with no results.

    If I use like
    Code:
    Like '*QLD*'
    then I get the correct results but when I use the iif I get nothing. If I don't put anything in the text box the true statement is ok and all results show.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Why do you need the IIf()? Why not just:

    Like "*" & [forms]![frmStatistics]![txtAreasfilter1] & "*"
    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
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Why do you need the IIf()? Why not just:

    Like "*" & [forms]![frmStatistics]![txtAreasfilter1] & "*"
    if text box is empty I want all the results to show, I am also filtering by date later but I want this to work first

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I've uploaded an image.

    I've used the WHERE group too with the same results and put the iif statement as a field to filter by 0 or 1 (sort of worked but won't help when I have null)

    Click image for larger version. 

Name:	Capture.PNG 
Views:	5 
Size:	6.8 KB 
ID:	18704

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    That should show all results if textbox is empty if used in criteria row - not seeing that.

    However, is it possible the field can be Null? Do you also want the records where field is Null?
    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.

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    oh sorry June, that works fine


    I tried that before but I had no success and thought I had something wrong - I must have missed something. Apologies!

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

Similar Threads

  1. Replies: 1
    Last Post: 02-03-2014, 03:06 PM
  2. Replies: 3
    Last Post: 03-23-2012, 01:38 PM
  3. Update Subform Recordsource
    By mystifier in forum Forms
    Replies: 8
    Last Post: 11-15-2010, 03:03 AM
  4. Group query results
    By shak2 in forum Access
    Replies: 7
    Last Post: 10-20-2010, 02:41 PM
  5. update recordsource of subform
    By AndyKim in forum Forms
    Replies: 1
    Last Post: 06-16-2009, 09:15 AM

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