Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

using filters openform macro

Forum home » Delegate support and help forum » Microsoft Access Training and help » Using filters in OpenForm macro action.

Using filters in OpenForm macro action.

ResolvedVersion 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

Edited on Wed 14 Mar 2012, 13:23

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

RE: Using filters in OpenForm macro action.

Hi Doug,
Spot on, that will save me having to create loads of pesky queries.
Cheers
Tim

Access tip:

Choosing data types in Access

Not sure which data type to use for your Access fields? Here are some guidelines to help you choose a data type to assign to a field.

- The Text data type can accept up to 255 characters. For information that will be recorded in paragraphs, use Memo.

- Also use Text for numbers that aren't going to be used in calculations, e.g. phone numbers.

- Use the Currency data type for monetary amounts.

- Use Date/Time for dates.

- Most other numbers can use the Number data type, but the Field Size property may have to be altered.

- For fields that have only two alternatives (yes, no) use Yes/No data type. If there is likely to be a third entry option (e.g. maybe or don't know) use Text instead.

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.13 secs.