Mig-O
asked on
Generic Filter Dialogs
Hi you all out there,
I need a nice filter Dialog for my application and are too lazy to write one on my own ;). No, I did one, but it sucks a bit, and I wanted to know if someone of you has written a filter dialog for your application before.
It is okey, if I have to customize it for every form (like adding the filterable fields and fieldtypes).
It should be something like choosing a value, thatn the operator, like "=", "<=" or "contains" ,and then a value that is given to the function.
Maybe someone has a download link for me?
I need a nice filter Dialog for my application and are too lazy to write one on my own ;). No, I did one, but it sucks a bit, and I wanted to know if someone of you has written a filter dialog for your application before.
It is okey, if I have to customize it for every form (like adding the filterable fields and fieldtypes).
It should be something like choosing a value, thatn the operator, like "=", "<=" or "contains" ,and then a value that is given to the function.
Maybe someone has a download link for me?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sure thing. If you need more information on my proposed solution, just ask. :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh, it would help if I gave you the plfilter code.
This code just goes in the forms module:
Public Function plfilter() As String
On Error GoTo plfilter_err
Dim tmpfilter As String
tmpfilter = "[" & Me.lstfields.Value & "]"
Select Case Me.frmsearch.Value
Case 1
tmpfilter = tmpfilter & " LIKE '*" & searchstring & "*'"
Case 2
tmpfilter = tmpfilter & " LIKE '" & searchstring & "*'"
Case 3
tmpfilter = tmpfilter & " Like '" & searchstring & "'"
End Select
plfilter = tmpfilter
Exit Function
plfilter_err:
plfilter = ""
Exit Function
End Function
perkc
This code just goes in the forms module:
Public Function plfilter() As String
On Error GoTo plfilter_err
Dim tmpfilter As String
tmpfilter = "[" & Me.lstfields.Value & "]"
Select Case Me.frmsearch.Value
Case 1
tmpfilter = tmpfilter & " LIKE '*" & searchstring & "*'"
Case 2
tmpfilter = tmpfilter & " LIKE '" & searchstring & "*'"
Case 3
tmpfilter = tmpfilter & " Like '" & searchstring & "'"
End Select
plfilter = tmpfilter
Exit Function
plfilter_err:
plfilter = ""
Exit Function
End Function
perkc
ASKER
This looks good, I will give it a try. But how do you deal with other datatypes, like numbers and dates?
I was only using it on string values.
You could store a value in the 'tag' property of the subform controls(n-number,t-text.. .)
Then when building the listbox values from the controls, make the name start or end with something to indicate the data type. This indicator would then be used when creating the filter.
Let me know if this is the method you want to go and need help modifying the code.
perkc
You could store a value in the 'tag' property of the subform controls(n-number,t-text..
Then when building the listbox values from the controls, make the name start or end with something to indicate the data type. This indicator would then be used when creating the filter.
Let me know if this is the method you want to go and need help modifying the code.
perkc
ASKER
Thank you for your comments.
I'll rate it B and share the points, because you showed me a direction what to do and could both give the one or other good idea, but its far from a complete solution (I will ask smaller questions the next times :). I hope I didn't dissapoint anyone.
Btw. sorry for not answering that long, I cancelled creation of this dialog for some time, if I finish it, you will both get a copy! :)
I'll rate it B and share the points, because you showed me a direction what to do and could both give the one or other good idea, but its far from a complete solution (I will ask smaller questions the next times :). I hope I didn't dissapoint anyone.
Btw. sorry for not answering that long, I cancelled creation of this dialog for some time, if I finish it, you will both get a copy! :)
ASKER