Results 1 to 6 of 6

ApplyFilter Macro to Select All Records on Form Not Working Properly

  1. #1
    msbecca23 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Oct 2019
    Posts
    3

    ApplyFilter Macro to Select All Records on Form Not Working Properly


    I have button on main form which calls Macro (mcrInitiateAllRecs) that utilizes ApplyFilter Action Command to call another query (qryInitiateMOCAllRecs) to display all records.
    Upon clicking button, the form does not refresh to show all records. (ie. Record: |< 1 of 20394 >|).

    I've single-stepped through macro and the dialog box shows arguments as: qryInitiateMOCAllRecs,,
    From my understanding, this should be not passing any filter criteria to the query, so it should return all records.
    BTW...the query does not contain any filtering logic in the SQL either.

    Why is this macro not operating as designed?
    Is there some hidden filter that is being passed to query that I am not aware of?

    Any help would be greatly appreciated.
    MsBecca23

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    48,225
    How does calling a query refresh a form? What is form's RecordSource? Why do you need to refresh form? Is a filter applied to form?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    msbecca23 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Oct 2019
    Posts
    3
    Hi June7 - Thanks for responding.

    Yes, main form (frmInitiateMOC) has a recordsource of qryInitiateMOCAllRecs (which returns all records from table...and query does not have any filtering logic applied in it).

    Let me explain the full scenario:
    1. Database launches and main form (frmInitiateMOC) displays with all records showing
    2. User then clicks (FindRequest) button on main form to be taken to another form (frmFindMOC) to enter search criteria
    3. After entering search criteria, user clicks button on (frmFindMOC) which generates SQL statement based on criteria specified
    then user is returned to main form (frmInitiateMOC) showing only records user's specified

    Here's a snippet of code:
    Forms![frmInitiateMOC].RecordSource = strSQL
    Forms![frmInitiateMOC].SetFocus

    4. After user has reviewed filtered data back on main form (frmInitiateMOC), when they click (SelectAll) button to show all records, form does not refresh.
    This is the issue I reported in my original post.

    Again, the SelectAll button on main form (frmIntiateMOC) calls ApplyFilter macro (mcrInitateMOCAllRecs) which references query (qryInitiateMOCAllRecs), but no filter criteria is being applied.
    There seems to be some hidden filter criteria being applied to query, but not sure from where.

    Hope this helps to better understand my scenario.
    msbecca23

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,582
    If I understand correctly, there's no filter involved. You've changed the record source of the form to a filtered SQL statement. You'd have to change it back to your unfiltered query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    48,225
    Instead of changing RecordSource, I prefer to apply filter. 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.

  6. #6
    msbecca23 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Oct 2019
    Posts
    3
    Thanks so much June7 and pbaldly for your recommendations! I will be sure to look into both.

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

Similar Threads

  1. Replies: 28
    Last Post: 01-24-2018, 05:14 PM
  2. Macro ApplyFilter Not Working...
    By Lobo in forum Macros
    Replies: 8
    Last Post: 02-02-2017, 11:43 AM
  3. FilterByForm Macro then ApplyFilter
    By dscottf in forum Macros
    Replies: 1
    Last Post: 10-28-2015, 04:58 AM
  4. Replies: 15
    Last Post: 10-02-2015, 12:07 PM
  5. Replies: 2
    Last Post: 06-17-2015, 12:20 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
  •  
Tech Forums: Microsoft Office Forums