Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 358
Default Enter parameter in MS Query for updating Pivot Table

Hi,

I've searched this site but I can't see a direct answer to what I am trying
to do.

I've set up a Pivot Table that accesses data from MS Access via MS Query.
the criteria is set to get records with a Dept = 800.

I can edit the query manually but how do I change this to Dept = 810 via VBA ?

The query in MS Query is as follows:

SELECT tbl_Comm_Data.RCV_RETL, tbl_Comm_Data.RCV_MARGIN
FROM `G:\00_CEN\Oth\Inventory Planning Reports\POL\POL`.tbl_Comm_Data
tbl_Comm_Data
WHERE (tbl_Comm_Data.DEPT_NO='800')


--
Andrew
211008
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 221
Default Enter parameter in MS Query for updating Pivot Table

G'day Andrew

Rather than Making this part of your Query a constant

WHERE (tbl_Comm_Data.DEPT_NO='800')

Make the Query reference the Dept_No via a control (User manually inputs the
Dept_No) or combo (Select from list)

Try something like this in this part of the code:

WHERE (tbl_Comm_Data.DEPT_NO= &"Forms!YourForm!YourControl"&)

The Syntax may not be quite correct, hopefully it will point you in the
right direct.

HTH
Mark.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,344
Default Enter parameter in MS Query for updating Pivot Table

Hi,

I would record the creation of the initial pivot table. Excel will create
an SQL statement for you in VBA. You can easily modify that code to pick of
entries for any variable within the spreadsheet or via a user form. When you
record it post a copy of the VBA code and we can help you with specific
answers.

--
Thanks,
Shane Devenshire



"Andrew" wrote:

Hi,

I've searched this site but I can't see a direct answer to what I am trying
to do.

I've set up a Pivot Table that accesses data from MS Access via MS Query.
the criteria is set to get records with a Dept = 800.

I can edit the query manually but how do I change this to Dept = 810 via VBA ?

The query in MS Query is as follows:

SELECT tbl_Comm_Data.RCV_RETL, tbl_Comm_Data.RCV_MARGIN
FROM `G:\00_CEN\Oth\Inventory Planning Reports\POL\POL`.tbl_Comm_Data
tbl_Comm_Data
WHERE (tbl_Comm_Data.DEPT_NO='800')


--
Andrew
211008

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 358
Default Enter parameter in MS Query for updating Pivot Table

Hi NoodNutt & Shane,

I think I've used NudeNutt's suggestion in a roundabout way. In Access I
created a new table called tbl_Dept_No. It has one field with one record in
it. I edited the query and added this table to the query with a join on the
Dept_No fields.

Now I can enter the required department number in the Access table and then
go to my Pivot Table, refresh it and get the required results.

I can update the table via SQL so problem solved.


Shane,

I did try to record the creation before you replied to me. I wasn't able to
change it to edit the query though.




--
Andrew


"ShaneDevenshire" wrote:

Hi,

I would record the creation of the initial pivot table. Excel will create
an SQL statement for you in VBA. You can easily modify that code to pick of
entries for any variable within the spreadsheet or via a user form. When you
record it post a copy of the VBA code and we can help you with specific
answers.

--
Thanks,
Shane Devenshire



"Andrew" wrote:

Hi,

I've searched this site but I can't see a direct answer to what I am trying
to do.

I've set up a Pivot Table that accesses data from MS Access via MS Query.
the criteria is set to get records with a Dept = 800.

I can edit the query manually but how do I change this to Dept = 810 via VBA ?

The query in MS Query is as follows:

SELECT tbl_Comm_Data.RCV_RETL, tbl_Comm_Data.RCV_MARGIN
FROM `G:\00_CEN\Oth\Inventory Planning Reports\POL\POL`.tbl_Comm_Data
tbl_Comm_Data
WHERE (tbl_Comm_Data.DEPT_NO='800')


--
Andrew
211008

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 221
Default Enter parameter in MS Query for updating Pivot Table

Happy to help Andrew

Thx for the feedback.

Regards
Mark.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Table queries not updating when parameter changes Benjamin Peikes Excel Discussion (Misc queries) 4 April 24th 12 12:03 PM
parameter and macro driven pivot table filter? Ryan Hartnett Excel Programming 0 October 25th 06 09:26 PM
Linking parameter query from Access to pivot table in Excel ken1975 Excel Discussion (Misc queries) 2 June 20th 06 01:51 PM
Parameter Query-enter just once for use in multiple places jrenzul Excel Discussion (Misc queries) 1 April 15th 05 11:08 PM
Pivot Table From Access Parameter Query Paul Smith[_4_] Excel Programming 1 January 13th 05 04:04 PM


All times are GMT +1. The time now is 03:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"