Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2004
    Posts
    173

    Unanswered: Turn Off Filter when a Form is Opened to a Specific Record

    I have a continuous form with a list of customers. When I double click a customer name, I am using the code below to open a form to a specific customer

    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "AddCustomer"
    stLinkCriteria = "[CustomerNo]=" & Me![CustomerNo]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    This opens the form to the desired customer - filtered

    How can I turn off the filter if the user wants to see the other records.


    I have another button on a Menu that opens the customer form unfiltered. But, once the form is opened filtered, it must be closed, then reopened using the button on the menu to see all customers.

    Thanks - AB

  2. #2
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    One option:

    Revise to:
    Code:
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "AddCustomer"
    stLinkCriteria = "[CustomerNo]=" & Me![CustomerNo]
    DoCmd.OpenForm stDocName
    Forms(stDocName).Filter = stLinkCriteria 
    Forms(stDocName).FilterOn True
    To remove the filter (within the "AddCustomer" form):
    Code:
    Me.FilterOn False
    Me.Requery
    have fun,
    tc

  3. #3
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Question

    Quote Originally Posted by tcace
    One option:

    Revise to:
    Code:
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "AddCustomer"
    stLinkCriteria = "[CustomerNo]=" & Me![CustomerNo]
    DoCmd.OpenForm stDocName
    Forms(stDocName).Filter = stLinkCriteria 
    Forms(stDocName).FilterOn True
    To remove the filter (within the "AddCustomer" form):
    Code:
    Me.FilterOn False
    Me.Requery
    have fun,
    tc
    Hi TC,

    How would you do that if it opens up as a Continuous form (datasheet view)??

    BUD

  4. #4
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    How would you do that if it opens up as a Continuous form (datasheet view)??
    Continuous form and Datasheet are 2 different things. I never use datasheet view (I haven't had a compelling reason to yet). In datasheet view, you don't have the ability to add a command button, which is the most likely place to put the code for removing the filter.

    You can set to continuous form and then format it to look like a datasheet in the detail section without losing the functionality of the form controls.

    tc

  5. #5
    Join Date
    Apr 2006
    Location
    Huddersfield, UK
    Posts
    154

    Wink

    You can use Access to create a button to remove filter sort.

    You can create a macro to remove the filtersort (either as a command or you may have to do a run command then select the command to run). Then add a button to the form, or

    Add the button "remove Filter Sort" to the toolbar in access or to a custom toolbar you may have made : or;

    i'm not sure if i am making this up, using the button wizard in think i have seen a button you can place yo remove filter sort... not sure on this thou' (should really check before posting)

    All worth a try;

    Dan
    sometimes simple is best.... and i'm just a simple fellow.

  6. #6
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Talking

    Quote Originally Posted by tcace
    Continuous form and Datasheet are 2 different things. I never use datasheet view (I haven't had a compelling reason to yet). In datasheet view, you don't have the ability to add a command button, which is the most likely place to put the code for removing the filter.

    You can set to continuous form and then format it to look like a datasheet in the detail section without losing the functionality of the form controls.

    tc
    Again thanks to you TC. Never thought about using a Continuous Form and formatting it to look like a Datasheet, must give that a try, IF that is an option in A97. (my job uses it still.....ew)

    Also thanks to you too Dan....never have created a Custom Toolbar yet, and maybe this is something to make a go of it.

    laterz
    BUD

  7. #7
    Join Date
    Apr 2006
    Location
    Huddersfield, UK
    Posts
    154

    Wink

    i recently had to do this for a friend, and i fpund out that the button wizard doesn't actually have it, although:

    Macro > Run Command > Command = RemoveFilterSort

    Save the macro, then you can either have your macro run from a toolbar, or stick in a button on the form to run the macro.

    Just thought it'd help;

    Dan
    sometimes simple is best.... and i'm just a simple fellow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •