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

subform filtering

P: 4
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
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,365
Please use Code tags.

Instead of Me.Filter you use Me.SubformName.Form.Filter
Jan 4 '08 #2

P: 4
I still can't get it to work. any other suggestions?
Jan 4 '08 #3

Rabbit
Expert Mod 10K+
P: 12,365
Did you also change the syntax for FilterOn?
Jan 5 '08 #4

Post your reply

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