Solved

open new form using existing filters

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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

14 Experts available now in Live!

Get 1:1 Help Now