Hallo!
Möchte in folgenden Code einfügen, dass Listenfeld2 abhängig von Listenfeld0 ist.
Wie kann ich fortfahren? Gibt es da bei der Mehrfachauswahl etwas zu beachten?
Private Sub Befehl0_Click()
Dim strSQL As String
Dim strC1 As String, strC2 As String
Dim Anz&, I&, tmp As Variant
strSQL = "SELECT TOP 10 [Sales Zahlen].Fondsname, Sum([Sales Zahlen].AuM_) AS SummevonAuM_, Sum([Sales Zahlen].NetflowsMTD) AS SummevonNetflowsMTD, Sum([Sales Zahlen].NetflowsYTD) AS SummevonNetflowsYTD FROM [Sales Zahlen]"
With Me.Liste0
Anz = .ItemsSelected.Count
If Anz <> 0 And Anz < .ListCount Then
For Each tmp In .ItemsSelected
strC1 = strC1 & "Country='" & .ItemData(tmp) & "' or "
Next tmp
strC1 = Left$(strC1, Len(strC1) - 4)
End If
End With
With Me.Liste2
Anz = .ItemsSelected.Count
If Anz <> 0 And Anz < .ListCount Then
For Each tmp In .ItemsSelected
strC2 = strC2 & "Konzern='" & .ItemData(tmp) & "' or "
Next tmp
strC2 = Left$(strC2, Len(strC2) - 4)
End If
End With
If strC1 <> "" And strC2 <> "" Then
strSQL = strSQL & " where (" & strC1 & ") and (" & strC2 & ")"
ElseIf strC1 <> "" Then
strSQL = strSQL & " where " & strC1
ElseIf strC2 <> "" Then
strSQL = strSQL & " where " & strC2
End If
strSQL = strSQL & " GROUP BY [Sales Zahlen].Fondsname ORDER BY Sum([Sales Zahlen].AuM_) DESC;"
'MsgBox strSQL
CurrentDb.QueryDefs("Abfrage1").SQL = strSQL
DoCmd.OpenQuery "Abfrage1", acViewNormal
End Sub
Möchte in folgenden Code einfügen, dass Listenfeld2 abhängig von Listenfeld0 ist.
Wie kann ich fortfahren? Gibt es da bei der Mehrfachauswahl etwas zu beachten?
Private Sub Befehl0_Click()
Dim strSQL As String
Dim strC1 As String, strC2 As String
Dim Anz&, I&, tmp As Variant
strSQL = "SELECT TOP 10 [Sales Zahlen].Fondsname, Sum([Sales Zahlen].AuM_) AS SummevonAuM_, Sum([Sales Zahlen].NetflowsMTD) AS SummevonNetflowsMTD, Sum([Sales Zahlen].NetflowsYTD) AS SummevonNetflowsYTD FROM [Sales Zahlen]"
With Me.Liste0
Anz = .ItemsSelected.Count
If Anz <> 0 And Anz < .ListCount Then
For Each tmp In .ItemsSelected
strC1 = strC1 & "Country='" & .ItemData(tmp) & "' or "
Next tmp
strC1 = Left$(strC1, Len(strC1) - 4)
End If
End With
With Me.Liste2
Anz = .ItemsSelected.Count
If Anz <> 0 And Anz < .ListCount Then
For Each tmp In .ItemsSelected
strC2 = strC2 & "Konzern='" & .ItemData(tmp) & "' or "
Next tmp
strC2 = Left$(strC2, Len(strC2) - 4)
End If
End With
If strC1 <> "" And strC2 <> "" Then
strSQL = strSQL & " where (" & strC1 & ") and (" & strC2 & ")"
ElseIf strC1 <> "" Then
strSQL = strSQL & " where " & strC1
ElseIf strC2 <> "" Then
strSQL = strSQL & " where " & strC2
End If
strSQL = strSQL & " GROUP BY [Sales Zahlen].Fondsname ORDER BY Sum([Sales Zahlen].AuM_) DESC;"
'MsgBox strSQL
CurrentDb.QueryDefs("Abfrage1").SQL = strSQL
DoCmd.OpenQuery "Abfrage1", acViewNormal
End Sub