Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here are some very rough notes notes. They are only minimally tested, and using IN would be a disaster with a lot of values, however, it would be easy enough to switch this round and use an excluded list. Perhaps you can get some ideas.</p> <pre><code>Dim oPTable ''PivotTable Dim oPM ''PivotMember Dim oFUpd ''PivotFilterUpdate Dim oChildren ''ChildMembers Dim fset ''FieldSet Dim sWhere As String Dim sTemp As String Dim sSQL As String Dim sDelim As String Dim aStates As Variant Dim i As Integer Dim rs As DAO.Recordset sDelim = """" aStates = Array("Cleared", "Checked") ''Possible states Set oPTable = Forms(0).PivotTable.ActiveView sWhere = vbNullString For Each fset In oPTable.FieldSets sTemp = vbNullString Set oChildren = oPTable.FieldSets(fset).Member.ChildMembers For i = 0 To oChildren.Count - 1 Set oPM = oChildren(i) Set oFUpd = oPM.Field.FieldSet.CreateFilterUpdate If aStates(oFUpd.StateOf(oPM) - 1) = "Checked" Then Select Case fset.BoundField.DataType Case adChar, adLongVarWChar sTemp = sTemp &amp; "," &amp; sDelim &amp; oPM.Caption &amp; sDelim Case adInteger sTemp = sTemp &amp; "," &amp; oPM.Caption Case adDate sTemp = sTemp &amp; ",#" &amp; oPM.Caption &amp; "#" Case Else '' The above is a very short list. '' Stop End Select End If Next If sTemp &gt; vbNullString Then sWhere = sWhere _ &amp; " AND [" &amp; fset.Name &amp; "] IN ( " &amp; Mid(sTemp, 2) &amp; ")" End If Next sSQL = "SELECT DISTINCT ID FROM [" &amp; oPTable.Control.DataMemberCaption &amp; "] " sSQL = sSQL &amp; "WHERE 1=1" &amp; sWhere Set rs = CurrentDb.OpenRecordset(sSQL) MsgBox "Unique: " &amp; rs.RecordCount </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload