?
Solved

Turn off Filter when a Form is Opened to Specific Record

Posted on 2006-05-09
5
Medium Priority
?
649 Views
Last Modified: 2012-05-05
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


0
Comment
Question by:abinboston
5 Comments
 
LVL 54

Expert Comment

by:nico5038
ID: 16640791
Use a button with:

me.filteron = false

Nic;o)
0
 
LVL 7

Expert Comment

by:DrewK
ID: 16640798
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
0
 
LVL 61

Expert Comment

by:mbizup
ID: 16640818
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
0
 

Author Comment

by:abinboston
ID: 16641035
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
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 16641689
I gave you bad advice on the Filter parameter in my last post... The filter parameter in the openform statement requires a query name.  Try this instead...

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

    '*** These 2 line work whether the target form is visible or not...
    Forms(stDocName).Filter = stLinkCriteria    'Setting the filter this way lets you use a string such as stLinkCriteria
    Forms(stDocName).FilterOn = True

0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question