Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

open new form using existing filters

Posted on 2004-03-27
5
365 Views
Last Modified: 2012-06-27
I am trying to have a simple button on a List form so that when you click on the Edit button on any of the records a new form is opened showing all of the information of that record, and both the recordset and filter is the same as was on the List(called the Edit form). The Source can be changed using a drop down menu in a toolbar that has macros that apply a source based on a predefined query. The filtering can be set via the normal 'Find' button on the Access 'Form View' toolbar. I am trying to do this via the where command where I have something like this:
stLinkCriteria = Screen.ActiveForm.Filter
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria, , ,
The form being opened simply comes up with no filter, although the recorset is being set correctly. How am I misusing the Where Command. I believe that an option is to do this:

    stLinkCriteria = Screen.ActiveForm.Filter
    DoCmd.Close
    DoCmd.OpenForm stDocName, , , "", , ,
Screen.ActiveForm.Filter = stLinkCriteria
Screen.ActiveForm.FilterOn = True
But in my experience this is both slower and makes the screen flash/flicker in an annoying way since it is loaded first without the filter. I do, however, NEED the Filter option within the form being opened to set, just changing the criteria with which it is opened is not good enough since, if the filter of this newly opened form is changed and then the user wants to go back to the list the filter used needs to be the new one set while the 'edit' form was opened. Make sense to anyone? Is it not possible to actually set the filter using the DoCmd.OpenForm command? Thanks
Jordan
0
Comment
Question by:jramrus
  • 3
  • 2
5 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 50 total points
ID: 10695774
I normally use a datasheet subform that can be filtered.
To activate a form for the filtered set I use:

IF me.subformname.form.filteron = true then
   docmd.openform "formname",,,me.subformname.form.filter
else
   docmd.openform "formname"
endif

Nic;o)
0
 

Author Comment

by:jramrus
ID: 10695860
So I am not using a datasheet subform, but besides that what is the difference? Me.form.filter doesn't return something different than Screen.ActiveForm.Filter does it?? Why else would yours work when mine doesn't??
0
 
LVL 54

Expert Comment

by:nico5038
ID: 10695886
No difference, but as yours doesn't work something must be wrong.
Try to add a field to the form named txtFilter and set in the OnCurrent event of the form:
me.txtfilter = me.filter
Thus making the filter visible when moving through the records.

Nic;o)
0
 

Author Comment

by:jramrus
ID: 10695922
I have been debugging in a similar manner by simply having a button that has 'MsgBox Screen.ActiveForm.Filter'
Without these:
    Screen.ActiveForm.Filter = stLinkCriteria
    Screen.ActiveForm.FilterOn = True
the output is blank, and with them the output and the filtering is correct. How does the where condition in the open statement know to over-ride the blank filter in the actual form properties of the form being opened. Do I need to somehow tell the form being opened to set the FilterOn and then open that form? Can I set the filter before the form is opened to prevent the flashing/flickering? If yours works and mine doesn't, I agree that something else is going on. Any ideas????
Thanks!
0
 
LVL 54

Expert Comment

by:nico5038
ID: 10695982
Passing the FilterCriteria in the parameter will set the filter to "On" and can be seen in the menu as the filterbutton will look pressed.

Can't you try to put the form as subform and try with my solution?

Nic;o)
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

790 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