Answered remove form filter?

  • Thursday, September 20, 2012 2:30 PM
     
     

    access2003.mdb

    a working form has a couple of comboboxes in header to select record.  one by name , one by ID  - all work fine.

    in a legitimate situation one needs to open this form, from another form, using the opening argument specifying the ID - so that it opens to a specific record.   this also works fine

    effectively this form then is filtered on this one record and the comboboxes in the header no longer work.  it is throwing off the user, though closing and reopening the form clears the filter of course....

    I'm wondering would it make sense and be possible to remove the filter perhaps via the form's timer?  I know it will take the user more than ~5 seconds to complete the form....if the timer removed the filter would the form not stay on its current record?  if so the header comboboxes would be working when the user goes to change records....

    presuming someone out there has approached this before would welcome input.....

All Replies

  • Thursday, September 20, 2012 2:44 PM
     
     
    msdnPublicIdentity wrote:
    > access2003.mdb
    >
    > a working form has a couple of comboboxes in header to select record.
    > one by name , one by ID  - all work fine.
    >
    > in a legitimate situation one needs to open this form, from another
    > form, using the opening argument specifying the ID - so that it opens
    > to a specific record.   this also works fine
    >
    > effectively this form then is filtered on this one record and the
    > comboboxes in the header no longer work.  it is throwing off the
    > user, though closing and reopening the form clears the filter of
    > course....
    >
    > I'm wondering would it make sense and be possible to remove the
    > filter perhaps via the form's timer?
    > ...
     
    A timer should always be the last resort as it may have side effects.
    Instead you could check if there is a filter set before you try to navigate:
     
    If Me.Filter > "" Then Me.Filter = ""
     
    ...here follows your navigation code
     
    --
    cu
    Karl
    *********
    Access-FAQ (German/Italian): http://www.donkarl.com
     
     
     
  • Thursday, September 20, 2012 2:46 PM
     
     

    Are you using the WhereCondition argument of the OpenForm Method to filter the Form being opened or are you passing the ID value through the OpenArgs and then your code navigates to the required Record?

    Basically, you need to use the later method (OpenArgs) then use code in the Form_Open Event to navigate to the required record without filtering the Form's Recordset.


    Van Dinh

    • Edited by Van DinhMVP Thursday, September 20, 2012 2:47 PM
    •  
  • Friday, September 21, 2012 1:23 PM
     
     

    thanks both KD and VD...  yes am using the Where - - has always been my default method ....  not familiar with the approach of passing the ID and then navigating....need to learn more on that....

  • Friday, September 21, 2012 1:38 PM
     
     Answered
    msdnPublicIdentity wrote:
    > ...yes am using the Where - - has always been
    > my default method ....  not familiar with the approach of passing the
    > ID and then navigating....need to learn more on that....
     
    It can all be done in the calling code:
     
    DoCmd.OpenForm "MyNextForm"
    Forms!MyNextForm.Recordset.FindFirst "ID =" & 99
     
     
    or by passing the criteria in the OpenArgs parameter:
     
    DoCmd.OpenForm "MyNextForm", , , , , , 99
     
    and then in the Open procedure of MyNextForm:
     
    If Not IsNull(Me.OpenArgs) Then
     
        Me.Recordset.FindFirst "ID=" & Me.OpenArgs
     
    End If
     
     
    --
    cu
    Karl
    *********
    Access-FAQ (German/Italian): http://www.donkarl.com
     
     
     
  • Friday, September 21, 2012 2:07 PM
     
     

    thanks KD that did the trick.  am going to note this approach for future reference.

    (just removing the filter caused the initial record to disappear and it reverted to the first record of the record set)

    thanks again.