none
Opening a form with a 'where' filter

    Question

  • When I open a form (docmd.openform) with the 'where' parameter, does this parameter influence the 'filter', 'filteron' and 'filteronload' properties of the form? i.e. does it set those properties?

    When I open a form without the 'where' parameter, does the omission of this parameter influence the 'filter' and 'filteron' and 'filteronload' properties of the form? i.e. does it clear those properties?

    Is there a way to clear the the 'filter', 'filteron' and 'filteronload' properties of a form when closing the form. What event would be appropriate?

    Thanks.

    Monday, November 19, 2012 5:26 PM

Answers

  • When I open a form (docmd.openform) with the 'where' parameter, does this parameter influence the 'filter', 'filteron' and 'filteronload' properties of the form? i.e. does it set those properties?

    Opening the form with the WhereCondition argument temporarily changes the Filter and FilterOn properties.  It doesn't change the FilterOnLoad property.  If you then close the form without filtering or unfiltering the form via the user interface, the temporary changes to the Filter property and FilterOn properties, made due to the WhereCondition argument, are not saved.

    If, after opening the form with the WhereCondition argument, you modify the filter via the user interface, the modified Filter is saved when you close the form.  I don't *think* the FilterOn property is ever saved, but I haven't tested that.

    When I open a form without the 'where' parameter, does the omission of this parameter influence the 'filter' and 'filteron' and 'filteronload' properties of the form? i.e. does it clear those properties?

    The Filter and FilterOnLoad properties will be left unchanged.  If FilterOnLoad is set, then FilterOn will be set if the Filter property is not blank; otherwise not.  So FilterOnLoad will cause the form to be filtered, if a Filter exists, even without the WhereCondition.

    Is there a way to clear the the 'filter', 'filteron' and 'filteronload' properties of a form when closing the form. What event would be appropriate?

    I don't think you should need to do that, and I'm not sure you *can* do it without putting the form into design view.  However, the behavior seems to have changed in A2010 from what it was in A2003, so I'm not completely sure of this answer.  In A2003, I recall having sometimes to clear the Filter property to cope with users filtering forms and clicking the Save button.  So you should experiment if it matters to you.


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    Monday, November 19, 2012 7:35 PM

All replies

  • Create a form that returns multiple rows. Open it to see all the data. Close it. Open it again using a Where parameter to see the reduced amount of data. Close it. Open it again. How much data do you see?


    Doug Steele, Microsoft Access MVP
    http://www.AccessMVP.com/djsteele (no e-mails, please!)
    Co-author Access Solutions — Tips, Tricks, and Secrets from Microsoft Access MVPs (ISBN 978-0-470-59168-0)

    Monday, November 19, 2012 6:45 PM
  • When I open a form (docmd.openform) with the 'where' parameter, does this parameter influence the 'filter', 'filteron' and 'filteronload' properties of the form? i.e. does it set those properties?

    Opening the form with the WhereCondition argument temporarily changes the Filter and FilterOn properties.  It doesn't change the FilterOnLoad property.  If you then close the form without filtering or unfiltering the form via the user interface, the temporary changes to the Filter property and FilterOn properties, made due to the WhereCondition argument, are not saved.

    If, after opening the form with the WhereCondition argument, you modify the filter via the user interface, the modified Filter is saved when you close the form.  I don't *think* the FilterOn property is ever saved, but I haven't tested that.

    When I open a form without the 'where' parameter, does the omission of this parameter influence the 'filter' and 'filteron' and 'filteronload' properties of the form? i.e. does it clear those properties?

    The Filter and FilterOnLoad properties will be left unchanged.  If FilterOnLoad is set, then FilterOn will be set if the Filter property is not blank; otherwise not.  So FilterOnLoad will cause the form to be filtered, if a Filter exists, even without the WhereCondition.

    Is there a way to clear the the 'filter', 'filteron' and 'filteronload' properties of a form when closing the form. What event would be appropriate?

    I don't think you should need to do that, and I'm not sure you *can* do it without putting the form into design view.  However, the behavior seems to have changed in A2010 from what it was in A2003, so I'm not completely sure of this answer.  In A2003, I recall having sometimes to clear the Filter property to cope with users filtering forms and clicking the Save button.  So you should experiment if it matters to you.


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    Monday, November 19, 2012 7:35 PM