Solved

open new form using existing filters

Posted on 2004-03-27
5
358 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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