This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
vba:classes:yfilter [23.12.2015 10:52:45] yaslaw |
vba:classes:yfilter [15.01.2016 11:46:56] (current) yaslaw |
||
---|---|---|---|
Line 1: | Line 1: | ||
<const> | <const> | ||
- | version=1.2.0 | + | version=2.1.0 |
- | vdate=09.12.2015 | + | vdate=15.01.2016 |
fname=yfilter.cls | fname=yfilter.cls | ||
ns=%NAMESPACE% | ns=%NAMESPACE% | ||
Line 36: | Line 36: | ||
? YFilter("mytable.id", 13).filterText | ? YFilter("mytable.id", 13).filterText | ||
[mytable].[id] = 13 | [mytable].[id] = 13 | ||
- | |||
- | ? YFilter("my table.meine datum", #31-12-2015#).filterText | ||
- | [my table].[meine datum] = #12/31/2015 00:00:00# | ||
? YFilter("name", "Yaslaw").filterText | ? YFilter("name", "Yaslaw").filterText | ||
Line 55: | Line 52: | ||
==== Direkte Filter ==== | ==== Direkte Filter ==== | ||
- | Manchmal macht es SInn, ein Filter direkt einzugeben. Zm Beispiel als Untefilter bei [[#createAnd]] | + | Manchmal macht es Sinn, ein Filter direkt einzugeben. Zm Beispiel als Untefilter bei [[#createAnd]] |
<code vb>? YFilter("id = 123").filterText | <code vb>? YFilter("id = 123").filterText | ||
id = 123 | id = 123 | ||
Line 64: | Line 61: | ||
==== Filter mittels Paramter konkretisieren ==== | ==== Filter mittels Paramter konkretisieren ==== | ||
- | Mit 2 Parametern kann man dem Filter auch auf die Sprünge helfen, damit klar ist, was man haben will. | + | Mit 3 Parametern kann man dem Filter auch auf die Sprünge helfen, damit klar ist, was man haben will. |
<code vb>'Ohne FilterType & ValueType | <code vb>'Ohne FilterType & ValueType | ||
? YFilter("id", "123").filterText | ? YFilter("id", "123").filterText | ||
Line 102: | Line 99: | ||
[id] NOT IN ("13", "42")</code> | [id] NOT IN ("13", "42")</code> | ||
- | Vergleichsvalue ist ebenfalls ein Feld | + | Einige Beispiele zu weiteren Parameter |
- | <code> | + | <code vb> |
+ | 'Logik umdrehen. Der erste Wert ist ein Value, die Zweiten sind Felder | ||
+ | ?YFilter("abc", array("Code1", "Code2"),,,efpFirstIsValue+efpSecoundIsName).filterText | ||
+ | ("abc" BETWEEN [Code1] AND [Code2]) | ||
+ | |||
+ | 'Wenn das erste Feld klar kein Feldname ist, dnn kann efpFirstIsValue auch weggelassen werden | ||
+ | ?YFilter(#05-15-2016#, array("from_date", "to_date"),,,efpSecoundIsName).filterText | ||
+ | (#05-15-2016 00:00:00# BETWEEN [from_date] AND [to_date]) | ||
+ | |||
+ | 'Ein Boolean-Text ohne Parameter efpParseBooleanString | ||
+ | ?YFilter("t2.flag1", "True").filterText | ||
+ | [t2].[flag1] = "True" | ||
+ | |||
+ | 'und mit Parameter efpParseBooleanString | ||
+ | ?YFilter("t2.flag1", "True",,,efpParseBooleanString).filterText | ||
+ | [t2].[flag1] = True | ||
+ | </code> | ||
===== Creatoren ===== | ===== Creatoren ===== | ||
==== instance ==== | ==== instance ==== | ||
- | <code>Set myFiler = YFilter.instance(feldName, [values [,filterType [,valueType]]]) | + | <code>Set myFiler = YFilter.instance(filterName, [values [,FilterType [,ValueType [,FilterParameters]]]]) |
- | Set myFiler = YFilter(feldName, [values [,filterType [,valueType]]])</code> | + | Set myFiler = YFilter(filterName, [values [,FilterType [,ValueType [,FilterParameters]]]])</code> |
- | <code vb> | + | <code vb>'/** |
- | ' * @param String Feldname/FilterString | + | ' * erstellt ein Filter und gibt den Filterstring zurück |
- | ' * @param Variant Ein Wert oder ein Array mit Werten | + | ' * @param String Feldname |
- | ' * @param eFilterType Type des Filters. eftNot lässt sich mit den restlichen kombinieren | + | ' * @param Variant Ein Wert oder ein Array mit Werten |
- | ' * @param eValueType Type des Vergleichsvalue | + | ' * @param eFilterTypes Type des Filters. eftNot lässt sich mit den restlichen kombinieren |
- | ' * @return YFilter | + | ' * @param eValueTypes Type des Vergleichsvalue |
+ | ' * @param eFilterParams Diverse weitere Einstellungen | ||
+ | ' * @return String | ||
' */ | ' */ | ||
- | Public Static Property Get instance( _ | + | Public Static Function instance( _ |
- | Optional ByVal iFieldName As Variant = Empty, _ | + | Optional ByRef iItems1 As Variant = Empty, _ |
- | Optional ByRef iValues As Variant = Null, _ | + | Optional ByRef iItems2 As Variant = Null, _ |
- | Optional ByVal iFilterType As eFilterType = eftAutomatic, _ | + | Optional ByVal iFilterType As eFilterTypes, _ |
- | Optional ByVal iValueType As eValueType = evtAutomatic _ | + | Optional ByVal iValueType As eValueTypes, _ |
- | ) As YFilter</code> | + | Optional ByVal iFilterParams As eFilterParams _ |
+ | ) As YFilter | ||
+ | 'Attribute instance.VB_UserMemId = 0 | ||
+ | Set instance = New YFilter | ||
+ | instance.construct iItems1, iItems2, iFilterType, iValueType, iFilterParams | ||
+ | End Function | ||
+ | </code> | ||
== Beispiel == | == Beispiel == | ||
Line 144: | Line 165: | ||
==== construct ==== | ==== construct ==== | ||
- | <code>Set myFiler = new YFilter: myFilter.construct feldName, [values [,filterType [,valueType]]]</code> | + | <code>Set myFiler = new YFilter: myFilter.construct [values [,FilterType [,ValueType [,FilterParameters]]]]</code> |
- | <code vb> | + | <code vb>'/** |
- | ' * @param String Feldname/FilterString | + | ' * Initialisiert ein Filterobjekt |
+ | ' * @param String Feldname | ||
' * @param Variant Ein Wert oder ein Array mit Werten | ' * @param Variant Ein Wert oder ein Array mit Werten | ||
- | ' * @param eFilterType Type des Filters. eftNot lässt sich mit den restlichen kombinieren | + | ' * @param eFilterTypes Type des Filters. eftNot lässt sich mit den restlichen kombinieren |
- | ' * @param eValueType Type des Vergleichsvalue | + | ' * @param eValueTypes Type des Vergleichsvalue |
+ | ' * @param eFilterParams Diverse weitere Einstellungen | ||
' * @return YFilter | ' * @return YFilter | ||
' */ | ' */ | ||
Public Function construct( _ | Public Function construct( _ | ||
- | Optional ByVal iFieldName As Variant = Empty, _ | + | Optional ByRef iItems1 As Variant = Empty, _ |
- | Optional ByRef iValues As Variant = Null, _ | + | Optional ByRef iItems2 As Variant = Null, _ |
- | Optional ByVal iFilterType As eFilterType = eftAutomatic, _ | + | Optional ByVal iFilterType As eFilterTypes, _ |
- | Optional ByVal iValueType As eValueType = evtAutomatic _ | + | Optional ByVal iValueType As eValueTypes, _ |
+ | Optional ByVal iFilterParams As eFilterParams _ | ||
) As YFilter</code> | ) As YFilter</code> | ||
Line 197: | Line 221: | ||
(([id] = 13) AND ([flag] = True)) OR (master = 0)</code> | (([id] = 13) AND ([flag] = True)) OR (master = 0)</code> | ||
+ | ===== Weitere Beispiele ===== | ||
+ | Siehe auch [[vba:flexiblerfilter]]. | ||
===== Code ===== | ===== Code ===== | ||
<source '%%fpath%%/%%fname%%' vb> | <source '%%fpath%%/%%fname%%' vb> |