473,804 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

subform filtering

4 New Member
I was researching some vba code on TheScripts.com and found this post. I’m looking to accomplish the same idea but I need to filter a sub form query with 3 combo boxes from the main form.

This is part of a tech support call log that I’m implementing as a sort of post production quality control log.

I appreciate any help you can give me







Re: ApplyFilter methodology


--------------------------------------------------------------------------------

On your form (Form Header section?), place 3 text boxes where the user can
enter values to filter on, and a pair of command buttons to apply and remove
the filter.

This example shows how to set the filter based on any combination of entries
from the 3 boxes:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdApplyFilter_Click
  2. Dim strWhere As String
  3. Dim lngLen As Long
  4.  
  5. If Me.Dirty Then 'Save first.
  6. Me.Dirty = False
  7. End If
  8.  
  9. 'Look at the text boxes where the user entered something.
  10. If Not IsNull(txtFindStatusType) Then
  11. strWhere = strWhere & "([Status Type] = " & _
  12. Me.txtFindStatusType & ") AND "
  13. End If
  14. If Not IsNull(txtFindDept) Then
  15. strWhere = strWhere & "([Department Number] = " & _
  16. Me.txtFindDept & ") AND "
  17. End If
  18. If Not IsNull(txtFindVendor) Then
  19. strWhere = strWhere & "([Vendor Name] = """ & _
  20. Me.txtFindVendor & """) AND "
  21. End If
  22.  
  23. 'Remove the trailing " AND ", and see what's left.
  24. lngLen = Len(strWhere) - 5
  25. If lngLen <= 0 Then
  26. MsgBox "No criteria"
  27. Else
  28. Me.Filter = Left(strWhere, lngLen)
  29. Me.FilterOn = True
  30. End If
  31. End Sub
  32.  
Jan 4 '08 #1
3 1590
Rabbit
12,516 Recognized Expert Moderator MVP
Please use Code tags.

Instead of Me.Filter you use Me.SubformName. Form.Filter
Jan 4 '08 #2
BSTAFFORD
4 New Member
I still can't get it to work. any other suggestions?
Jan 4 '08 #3
Rabbit
12,516 Recognized Expert Moderator MVP
Did you also change the syntax for FilterOn?
Jan 5 '08 #4

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

Similar topics

3
11109
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
3333
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...
0
1943
by: johnson_cy | last post by:
I am using Access 2000. My main form has a record source of a table (employeeTbl with key of . It is filtering the record results. My subform and mainform have the link child/link master set to and the source object is the subform. My subform record source is a query from another table (vacationTbl). FYI: I was filtering on the subform, but removed it and replaced with
2
4808
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
11976
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
4939
by: aintnorock | last post by:
I have a relatively simple relational database. One of my forms is based on a query with a 3 parameter sort: Status / Priority / Customer. When I open the form, the records are sorted properly. When I go to filter the form, to get a subset of the form, e.g. filter by Responsible Party, I would like the form to sort this way: Reposponsible Party / Status / Priority / Customer.
2
4292
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
5390
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
1701
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
2183
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
9594
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
10599
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
10346
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
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7635
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
5531
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
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
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.