473,672 Members | 2,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

applying a filter to a form that has a subform

43 New Member
Hi - I have a form called Vendor (tied to table with same name). Each vendor_id can belong to more than one 'category'. So there's a table called Vendor_Category which contains just vendor_id and category.

On the Vendor form, there's a subform called Vendor_Category . When a user is in the Vendor form and is in a record for a particular vendor_id, they use a combo_box in the Vendor_Category subform to select Vendor_Categori es that can belong to the Vendor in question.

That works fine, but now I want to filter by Vendor_Category and just see vendor records the belong to a certain category. So I added an unbound vendor_category combobox which just contains a list of all the different categories. When a user selects one from the list, I've added code in the AfterUpdate that I want to use to set the filter.

Unfortunately, I have no clue how to write the filter. I know I set the filter and then turn the filter on. But the syntax is a mystery to me.

Any help would be greatly appreciated.

Thanks,
Bill
Aug 27 '09 #1
13 2108
ChipR
1,287 Recognized Expert Top Contributor
The Form.Filter Property is just like a Where Condition, so something like:
Expand|Select|Wrap|Line Numbers
  1. Me.Filter = "[Category] = '" & cboVendorCategory & "'"
  2. Me.FilterOn = True
Aug 27 '09 #2
bkberg05
43 New Member
Hi and thanks,

The part that's giving me trouble is the [Category] section in your example. When the event runs, it opens up a dialog box asking for the parameter value.

When I'm putting in the code and I put the field in as [category] with lower space, it doesn't recognize it and change it to uppercase. I thought maybe it was because it was on a subform, but even when I put in a field from the main form, it still doesn't change to upper case.

Note the following information:
1. Main form name is "Vendor". It's Record Source is the "Vendor" table. "Vendor_ID" is the primary key.
2. Sub_form name on the main form is called "Vendor_Categor y_sub". The Source Object for the subform is the form "sub_Vendor_Cat egory". The Link Child and Link Master fields are both "Vendor_ID" .
3. On the form "sub_Vendor_Cat egory", the Record Source is the "Vendor_Categor y" table which contains only "Vendor_ID" and "Vendor_Categor y" fields. The "Vendor Category" field is what I'm trying to filter on.
4. The combo box on the "Vendor" form that I'm using to trigger the filter is called "Vendor_Categor y_Filter".

Just wanted to be thorough. I've checked to see if the [vendor_category] name was duplicated somewhere, but I can't find another instance.

Thanks again for any future help.
Aug 27 '09 #3
ChipR
1,287 Recognized Expert Top Contributor
[Category] in the code should be replaced with the name of the field in the main form's underlying recordset.
Aug 27 '09 #4
bkberg05
43 New Member
yes, did that. Here's my actual code

Me.Filter = "[vendor_category] = '" & Me.Vendor_Categ ory_Filter & "'"
Me.FilterOn = True
Aug 27 '09 #5
ChipR
1,287 Recognized Expert Top Contributor
If it's still asking for a parameter value, then "vendor_categor y" is not the name of a field in the recordset you are trying to filter.
Aug 27 '09 #6
bkberg05
43 New Member
Agreed. The field name is definitely "vendor_categor y". But as it's on a sub-form, somehow it must not be part of the recordset? If I change the name to a field on my Vendor form such as "vendor_nam e" for instance, it recognizes it fine.

Either i'm referring to the field wrong (by not referencing the sub_form name) or the recordset needs to be expanded to include the data in the sub form and i don't know how to do that.
Aug 27 '09 #7
ChipR
1,287 Recognized Expert Top Contributor
To filter the subform, you would use:
subformControlN ame.Form.Filter = ...
Aug 27 '09 #8
bkberg05
43 New Member
Here's what I wrote. It now says 'Object Required' in the debugger. Maybe I don't know how to reference the [vendor_category] field correctly as it is also in the subform...

Vendor_Category _sub.Form.Filte r = "[vendor_category] = '" & Vendor_Category _Filter & "'"
Vendor_Category _sub.Form.Filte rOn = True
Aug 27 '09 #9
ChipR
1,287 Recognized Expert Top Contributor
Make sure that Vendor_Category _sub is the name of the control on the main form.
Aug 27 '09 #10

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

Similar topics

1
7843
by: Robert Neville | last post by:
I would like to add filter functionality to my database whether through the Main form or the subform. This question may be rudimentary, yet I have not less experience with filtering data outside from queries. Let me just add that Allen Browne excellent article about this subject may not apply to this scenario on an elementary level. (Here's the link to the article; Filter a Form on a Field in a Subform -...
7
6280
by: damjanu | last post by:
Hi All; I need little help. I have a datasheet form. I allow user to do 'filter by selection'. My form contains a column with values. As user changes selections, I want to calculate totals. I can do this the first time the form loads.
2
2841
by: cefrancke | last post by:
I have a form (no underlying record set) that has two separate sub-forms on it. Each sub-form has data from two different tables. Above each sub-form there is one unbound combo box with a SQL record source that returns an ID field and a Text field. Next to each combo box is two buttons, one that 'Applys' the filter of the sub-form to the value in the combo box and one that 'Clears' the form's current filter. When the click event of the...
4
3570
by: MS | last post by:
I'm having trouble applying a filter to a subform. I create a String in a Module based on various selections on the form. Clicking a button on the "stand alone form" that changes the filter property string to the string from the module works fine. As soon as I put the form on the "main form" (thereby coverting it to a sub form) things no longer work. Of course the record source for the sub form is no longer a table or query, but the...
3
11961
by: dhowell | last post by:
In reading some of the posts on this group, it appears as though it is not strait forward at all to filter a form, which has subforms, by criteria which are either on subforms or span more than one subform..... This MSDN article however makes it sound as simple as clicking "Filter by Form", entering the search criterial in the form and/or it's subforms, then just clicking "Apply Filter"...... ...
1
1537
by: jcf378 | last post by:
Is it possible to set a main-form with an embedded subform to "Filter by Form", subsequently enter the desired variables in fields in BOTH the main-form and subform, and then save the resulting filter as a single query? or, do the variables entered on the main form need to be saved as its own individual query, and the variables entered on the subform saved as a separate query. I ask because I would ideally like to take a single query,...
2
2889
by: jambonjamasb | last post by:
What I am trying to do is have a combo box which allows me to filter for a certain field in a subform. I can't think how to do this and have tried with the follwoing code. Basically the field in question is : POL_Change_Allocated - This is a yes/no tick box. I want to filter for all forms where the tick hasn't been applied. (Am I right in thinking that this means this field is no unless ticked?) The main form feeds from table OCP Base...
9
3079
by: angi35 | last post by:
Hi - In Access 2000, I have a form I want to filter, but I can't get the syntax right in the code. Form: Subform: Control on : txtStart Nested Subform on : Control on : txtSDate
0
1686
by: diogenes | last post by:
"Rick Brandt" <rickbrandt2@hotmail.comwrote in news:bPnKj.456$%41.325 @nlpi064.nbdc.sbc.com: I used this approach, and it works a treat! ID In(SELECT Order_ID FROM orderitems WHERE NAME = 'product') I've not used an In clause before. Thanks a lot for the education.
0
8485
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8605
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6238
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4417
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.