Link to home
Start Free TrialLog in
Avatar of abinboston
abinboston

asked on

Turn off Filter when a Form is Opened to Specific Record

I have a continuousform with a list of customers. When i double click a customer name, I am using thecode 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 isopened filtered, it must be closed, then reopened using the button on the meun to see all customers.

Thanks - AB


Avatar of nico5038
nico5038
Flag of Netherlands image

Use a button with:

me.filteron = false

Nic;o)
Avatar of DrewK
there should be a filter button (looks like an funnel) in the toolbar, no?

This toggles the filter on and off.

just making sure,

Drew
Try using the filter parameter of the openForm statement instead of the Where condition, like this:

Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "AddCustomer"
    stLinkCriteria = "[CustomerNo]=" & Me![CustomerNo]
    DoCmd.OpenForm stDocName, , stLinkCriteria
    Forms(stDocName).FilterOn =True


Then when the user needs to remove the filter, this code in the command button click (or what ever event you are using for this):

Me.FilterOn = False
Avatar of abinboston
abinboston

ASKER

OK... I tried this

  Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "AddCustomer"
    stLinkCriteria = "[CustomerNo]=" & Me![CustomerNo]
    DoCmd.OpenForm stDocName, , stLinkCriteria
    Forms(stDocName).FilterOn = True

works ok... if the form is closed and opened using the code above

but... i am hiding the customer form once opened (using a close button -me.visible = false) - it takes 7-10 seconds to load... so when it is open, and hidden, the above does not work..

My original code does show theform, and go to the desired record.

Any Ideas on how to navigate to a desired record when the form is already opened, but hidden?


Also..either way, the toolbar filter button is not enabled. I have AllowFilters set to ZYes..


Thanks - AB
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial