473,387 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Update subform Pivot table off Listbox selection

I have a pivottable built off a query that is used to populate the listboxes, 1 for location 1 for category.

Those fields are included in the query to generate the sums based on the age of each record. ie, <15, 15-20 and >20 days old.

After selections made in listboxes, I am able to generate a detail page that allows users to be able to review the individual records. They would like to have the pivot table change to show how many records are selected by age

I have tried this to reset the record
Expand|Select|Wrap|Line Numbers
  1.   Dim stdocname As String
  2.     Dim strwhere As String
  3.     Dim sSql As String
  4.  
  5.     strwhere = "1=1 "
  6.     strwhere = strwhere & ListSelections(Me.WorkByCommodity, "[category]", "'")
  7.     strwhere = strwhere & ListSelections(Me.workbyLocation, "[Location]", "'")
  8.     Debug.Print strwhere
  9.     sSql = "SELECT qry_Expedites_With_Comments_1.Category, qry_Expedites_With_Comments_1.Location, Sum(IIf([expr1]<15,1,0)) AS [<15], "
  10.     sSql = sSql & " Sum(IIf([expr1]>=15 And [expr1]<=20,1,0)) AS [15-20], Sum(IIf([Expr1]>20,1,0)) AS [>20]"
  11.     sSql = sSql & " FROM qry_Expedites_With_Comments_1"
  12.     sSql = sSql & " where " & strwhere
  13.     sSql = sSql & " GROUP BY qry_Expedites_With_Comments_1.Category, qry_Expedites_With_Comments_1.Location;"
  14.  
  15.     Debug.Print sSql
  16.  
  17.     Me!sfrm_ExpeditesbyLocationchart.Form.RecordSource = sSql
  18.  
But when that runs, it changes the pivot table to show nothing. Instead of the 77 records that show up on the details page.
Here is what the sSql showed when ran.
Expand|Select|Wrap|Line Numbers
  1. SELECT qry_Expedites_With_Comments_1.Category, qry_Expedites_With_Comments_1.Location, Sum(IIf([expr1]<15,1,0)) AS [<15],  Sum(IIf([expr1]>=15 And [expr1]<=20,1,0)) AS [15-20], Sum(IIf([Expr1]>20,1,0)) AS [>20] FROM qry_Expedites_With_Comments_1 GROUP BY qry_Expedites_With_Comments_1.Category, qry_Expedites_With_Comments_1.Location HAVING 1=1  AND [Location] In ('MAP') ;
  2.  
Jun 24 '10 #1
0 1240

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rob | last post by:
I'm just getting around to using pivot tables and charts. I find the Pivot table interface to be INCREDIBLY frustrating. When I view a table in Design view, then choose Pivot table view, I get...
4
by: Alan Lane | last post by:
Hello world: I'm including both code and examples of query output. I appologize if that makes this message longer than it should be. Anyway, I need to change the query below into a pivot table...
1
by: Grey | last post by:
I have created a asp.net form for user to input data. After input the data, user need to click a button to export the input data to excel for data analysis with excel pivot table function. is it...
9
by: PeteCresswell | last post by:
I've got something called "Reference Rates". The idea is that on a given day, we have various rates of return for various entities. e.g. Libor 3-month return, Libor 6-month return, US Treasury...
8
by: PhilBowen | last post by:
I have created a pivot table making reference to a query. It works perfectly well. However, when I go out of the database and then back in the pivot table appears as a "form". I can click on the...
5
by: Pourya99 | last post by:
Hello, I have an Access Data Access Page which has a pivot table. The data source of the pivot table is a SQL database table. The data in the pivot table itself is not a problem. I have a text...
12
by: kabradley | last post by:
Hello, Thanks for looking at my post and hopefully having an answer or at least a suggestion to my problem. I currently work at a financial planning office that deals with many clients and accounts....
5
by: Randy | last post by:
Hi, I'm have a form with a listbox and a few textboxes on it. Based on the user's selection in the listbox, I want the bindingsource to update the textboxes with the corresponding values. I have...
8
by: NJonge01 | last post by:
Great thanks to all the helpful responses I've read! Recently using MS Access after a lengthy (7-10 years) away from the tool. I apologize for posting a question that for all intents & purposes...
3
by: apank | last post by:
I have been working with VBA for less than a year, but mostly in Access. I have come accross an issue in Excel that I want to solve programatically. I have several pivot tables on one work sheet...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.