By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,519 Members | 1,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,519 IT Pros & Developers. It's quick & easy.

How to apply filter in Macros in Microsoft Access 2007?

P: 1
Good day
I'm Trying to apply filter in Macros in Microsoft Access 2007 but I failed in typing (where condition) in Macros.

I want to create a split form with a search text box above actually like a drop down list when I select a specific person in the text box a list of his clients will appear in the subform.. I tried to do that with (apply filter - Macros) but I failed

can you help me with this ??
May 13 '15 #1
Share this Question
Share on Google+
2 Replies


P: 40
Hello ka2015.
I'm not the best person to answer this, but I'll give you a method that worked for me.

I bear in mind that:
a. on the main form, you have the field you require as a source field for your filter (in this case, person's ID, person's name, or person's initials field(s), depending on what applies for you).
b. you have the target query (in this case, the clients table or query)
c. on the clients query, there is a field for details of the filter (i.e. the person in 1. above).

Having fulfilled a., b., and c., above:

1. Open your main form in design view. Ensure you have the required fields (as in a. above)
2. From the navigation pane, select your target query (the clients query) and drag it to the main form.
The sub-form wizard dialog opens, asking you to define which fields on your form link to your sub-form, or to choose the provided list
Select the option Define my own. In the drop down given, select the fields on your form which you want to link on your sub-form (i.e. if, Main Form field is Initials, Sub-form field must be Initials - fields having similar data types and data entries).
3. Click Next. Name your sub-form, then Finish.
Save your form.

In the Form view, you will notice that the person on the main form has their respective clients in the sub-form.

To create the drop-down control,
4. Return to Design View
5. On the Design tab, select option Combo Box
6. Draw the combo box on a blank space in your main form.
7. The combo box wizard dialog opens
8. Select the lowest option: "Find a record in my form based on the value I selected in my combo box".
9. Click Next. Choose the Field (e.g. ID or Initials or Person's Name, as in a. and step 2. above)
10. Click Next, up to the last screen for naming your combo box. Click Finish.
You have just completed your look-up form! :)

In the form view, you can use the combo box to select from the list which person on the main form you would like to view.
Below, in the sub-form, the respective person's list of clients is displayed, based on your selection.

All the best, as you accomplish this!
May 13 '15 #2

zmbd
Expert Mod 5K+
P: 5,397
KA2015
These are much more easily accomplished using VBA.
Unless you are planning to publish to SharePoint or WebApp you should consider moving away from ACC-Macro development and instead turn to VBA.Access / VBA Insights Sitemap [/url]
You will find several links in our Access-Insights section covering several filtering methods:
-filtering-
Another problem is the use of the "Split Form"
These forms are extremely problematic in the long run.
If you are actually using the "split form," and not the parent-child-form as Shem-K appears to have constructed, then your control should be in the header and you will need to do some coding to apply the filters to the form's filter property.

I'm on my way out the door for the day; however, I'll try to look into the macro side of this tomorrow.

-z
May 13 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.