473,394 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

subform filtering

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 1563
Rabbit
12,516 Expert Mod 8TB
Please use Code tags.

Instead of Me.Filter you use Me.SubformName.Form.Filter
Jan 4 '08 #2
I still can't get it to work. any other suggestions?
Jan 4 '08 #3
Rabbit
12,516 Expert Mod 8TB
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
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...
2
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...
0
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...
2
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. ...
3
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...
1
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. ...
2
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: ...
3
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...
0
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 =...
2
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...

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.