Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pivot Table: Filter from Array

Status
Not open for further replies.

CWalsh87

Technical User
Dec 15, 2010
16
0
0
Hi,

I'm really having problems with this and looked all over for an answer. I have a pivot table in a form, with a list box (based on a table).

I want to be able to click a button and the pivot table to be updated based on the values in the listbox.

What I have done is create and array from the listbox, but i can't seem to get the table to update from this. When I run this code access crashes?


Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim col()
Dim I As Integer
I = 0
Set db = CurrentDb
Set rs = db.OpenRecordset("tblTempList")
Do While Not rs.EOF
I = I + 1
ReDim Preserve col(I)
col(I) = rs![Item-no]
ar1 = Array(col(I))
rs.MoveNext
Loop

    Dim vntArray As Variant
    Dim strBuf As String
    Dim Results As String
    Dim intIndex As Integer
     
    vntArray = col()
    For intIndex = LBound(vntArray) To UBound(vntArray)
        strBuf = strBuf & "Index " & intIndex & " = " & vntArray(intIndex) & vbLf
       Next

Me.subfrmDeliveries.Form.PivotTable.ActiveView.RowAxis.FieldSets(1).Fields(0).IncludedMembers = vntArray

Any help would be greatly appreciates

Thanks
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top