98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Access Training and help » Using filters in OpenForm macro action.
Using filters in OpenForm macro action.
Resolved · Urgent Priority · Version 2007
Timothy has attended:
Access Advanced course
Using filters in OpenForm macro action.
Using a series of buttons one one form (A) to open another form (B). The buttons on A are all using the OpenForm action and are filtering form B through the use of queries. Form A itself is based on a query.
I know that a control value can be used to filter form B but do not want to put text boxes on form A to achieve this and given that there is the potential for form A to have a lot of buttons I need to find a less long winded way of filtering the form.
I only need to filter one field in form B to achieve what I want. Should I try and input an SQL Where clause into the other action argument. If so, would I only need to state the field I want to limit or all fields on form A.
Or can I put a simple expression in the Filter field like [Forms].[FormName].[FieldName] = ValueIWant.
Cheers
Tim
RE: Using filters in OpenForm macro action.
Hi Tim
Sounds like you are on the right lines with adding an expression to filter form B. Add the expression to the Where Condition for the OpenForm action.
As an example I tried it for a form called [Personal Details Form] which contains a [Job Code] field. Clicking a button runs a macro that opens a [Job Details form] filtered to show the job description for the person displayed in the [Personal Details Form].
This is the Where Condition
[Forms]![Personal Details Form]![Job Code]=[Job Details]![Job Code]
Note the expression relates the field on one form (form A) to the field in the Table or Query that is the control source for form B.
I hope this helps and if you can relate this to your example.
Regards
Doug Dunn
Best STL
RE: Using filters in OpenForm macro action.
HI Doug,
Thanks for the reply, my situation is a little different in that I don't have a field to relate to the Query that is the control source for the next form.
I am using buttons that run macros to open the form.
What I want to do (using your example) is substitute [Forms]![Personal Details Form]![Job Code] with a text value.
Would it be correct to say "text value" = [Job Details]![Job Code] and this would filter form B with the text value entered?
Cheers
Tim
RE: Using filters in OpenForm macro action.
Yes the Where Condition can include a "text value" but the value would be on the right of the = sign.
For example,
[Job Details]![Department]="Training"
I've just tested and click the button on Form A displays all job records in the Training department.
Here Department would be a field in Form B following your example.
Doug
Training information:
See also:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Access tip:Random samplingData is th key to a good database, therefore checking is essential. |