473,662 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with subform filtering

22 New Member
I am trying to filter a subforms combolist options through a combolist on the main form. Heres what i have:

Form: frmOrderDetail
Datasource: tblOrders
cmbOrderSupplie rID w/ control source orders.[ordersupplierid]

Subform: frmOrderDetailS ubform
datasource: qryOrderDetails
cmbItemID w/ row source:
SELECT [items].[itemid], [items].[itemname]
FROM items
WHERE items.[itemsupplierid]="& [Forms!].[frmOrderDetail].[cmbOrderSupplie rId] & "
ORDER BY [items].[itemname];


Can someone please help, i hope this isnt too confusing
May 2 '06 #1
1 1606
CaptainD
135 New Member
I assume you are using MS Access

Are you wanting to filter the information through the query or do you want to place the data into the form and then Filter the form?

When you place data in a form you filter by:

This example (and there are other ways to do it) passes the information to the form level variables and then filters based off the values. you could also pass the values to the sub.

I did it this way because I use it for forms and reports.

Expand|Select|Wrap|Line Numbers
  1. Private iFilterCode As Integer
  2. Private sFilterName As String
  3. Private iAccountCode As Integer
  4.  
  5. Option Compare Database
  6. Option Explicit
  7.  
  8. Private Sub cboRequestFilter_AfterUpdate()
  9.     iFilterCode = framFilter.Value
  10.     sFilterName = cboRequestFilter.Text
  11.     Call FilterForm(Me, sFilterName, iFilterCode)
  12.  
  13.  
  14. End Sub
  15.  
This is in a module
Expand|Select|Wrap|Line Numbers
  1. Public Sub FilterForm(FormName As Form, FilterBy As String, iFilterField As Integer)
  2. Dim sFieldName As String
  3. On Error GoTo ErrHandler
  4.  
  5. Select Case iFilterField
  6.     Case 1
  7.         sFieldName = "Submitted"
  8.     Case 2
  9.         sFieldName = "ProgramSupervisor"
  10.     Case 3
  11.         sFieldName = "ProgramManager"
  12. End Select
  13.  
  14.  
  15. If FilterBy = "All Request" Or FilterBy = "" Then
  16.     FormName.FilterOn = False
  17.     FormName.Requery
  18.     Exit Sub
  19. Else
  20.     FormName.Filter = sFieldName & " = '" & FilterBy & "'"
  21.     FormName.FilterOn = True
  22.     FormName.Requery
  23. End If
  24.  
  25. Exit Sub
  26. ErrHandler:
  27.     MsgBox "Error filtering data, error # " & Err.Number & ", " & Err.Description, vbOKOnly, "Error"
  28.  
  29. End Sub
  30.  
May 2 '06 #2

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

Similar topics

3
11097
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I have a primary form named TestResults, which is connected to data in a table named TestResults. There are basically two other tables that are related to the TestResults table (and the primary form) named Names-Normalized and SiteAddresses. The...
2
3315
by: Cameron | last post by:
Hi, For the database I am currently working on, my employer would like the ability to use multiple combo boxes in order to filter the database. For instance the structure of the company is based on regions, which are managed by a number of coordinators, who oversee a large group of associates. I would like to use a combo box so that people accessing the database can choose a particular region and then have a second combo box that only...
3
2607
by: Todd | last post by:
Hi, I've been told in another forum that I can apply a filter to a subform (from a control on the main form) by using the following code: Me.sfrMySubform.Filter = " = 7" I've tried this solution but it isn't working for me. Here's my code: Private Sub fraShowRows_Click()
2
4792
by: origin197511 | last post by:
Hello all... I'm having an issue with MSAccess 2000. I have a Form that holds records of my cartridge loads for a rifle and a subform that lists all groups that have been fired with that load. They are linked by the load_id field and when I just browse through the loads everything shows up correctly. Each recorded group is displayed on a line of the datasheet subform. However, when I filter the form for say my "Selected" flag...
3
11959
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"...... ...
3
5336
by: Mike Jakes | last post by:
I hope that someone can offer a little advice on this one - I've searched the group but can't find an answer. I think that I'm doing something really stupid or missing something trivial, but see what you can make of this... I have a main form "Events" that contains a tab control. The tab control has 7 pages. The 7th page (named "Boats") contains a subform called "BoatEventssubform". On this sub-form are two combo boxes, named...
2
4287
by: David W. Fenton | last post by:
I think at various times we've all encountered this problem: A subform is on a main form. From the code of the main form we refer to some property of/control on the child form thus: Me!subForm.Form!txtTextBox and for some reason, in certain contexts, we get the error: Error 2455: You entered an expression that has an invalid reference
3
5379
by: paquer | last post by:
On my Main form I have a Command Button that opens a Subform in order to create a new Subform record. At this point I want the subform to show only the new record being created. Not all the records the subform's table has. I cannot put the subform as Data Entry because I cannot print the main form & subform together if the subform is "data entry". (comes up blank every time)
0
1685
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.
2
2170
by: Element | last post by:
I have a master form with a simple subform that displays line items in datasheet mode. Everything works fine, except that when the subform has the focus, the standard Access sorting and filtering toolbar buttons are not available. I also tried a custom toolbar, but they are disabled there too. It seems odd, because when the same records are diplayed on their own "master" form in datasheet mode, those same toolbar buttons are available....
0
8432
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
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8856
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...
0
8762
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5653
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
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1747
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.