Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

open new form using existing filters

Posted on 2004-03-27
5
Medium Priority
?
390 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
[X]
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
  • 3
  • 2
5 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 200 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 your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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…
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 …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

604 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