Solved

open new form using existing filters

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sum Multiple Columns in Access Query 5 51
Newbie needs help printing from a form. 10 20
Run Time Error 3071 26 40
subform is not filtered by link field 8 21
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

861 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now