Language:

MS Access: Multiselect in Queries

Language: Deutsch
Programming Language: VBA
Published by: ralf
Last Update: 5/8/2006
Views: 959

Description

In MS Access verwendet man in den Benutzerschnittstellen gern Listen mit Multiselect-Funktion, um dem Anwender flexiblere Auswahlmöglichkeiten zu bieten.

In Queries ist es jedoch etwas schwierig diese Optionen abzufragen. Folgende VBA-Funktion schafft da Abhilfe:

Code

1 Function InMultiSelect(frms, ctrl As String, col As Integer, data As Variant, ParamArray OtherArgs()) As Boolean 2 'Checks whether a Variant (data or OtherArgs) is included in the specified column (col) of a ListBox (ctrl) 3 'in a certain Form (frms) 4 On Error GoTo Error_InMultiSelect 5 Dim varItm As Variant 6 Dim index As Integer 7 Dim ctl As Control 8 Dim frm As Form 9 Set frm = Forms(frms) 10 Set ctl = frm.Controls(ctrl) 11 InMultiSelect = False 12 For Each varItm In ctl.ItemsSelected 13 If InMultiSelect = True Then Exit For 14 If CStr(data) = CStr(ctl.Column(col, varItm)) Then InMultiSelect = True 15 For index = LBound(OtherArgs) To UBound(OtherArgs) 16 If InMultiSelect = True Then Exit For 17 If CStr(OtherArgs(index)) = CStr(ctl.Column(col, varItm)) Then InMultiSelect = True 18 Next index 19 Next varItm 20 Exit Function 21 22 Error_InMultiSelect: 23 InMultiSelect = False 24 Exit Function 25 End Function

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS