Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Passing criteria from one Excel Query to another

The following SQL code is from a query I run in excel as part of a VBA
macro I wrote. You can see that it prompts me for 2 date parameters
and a division parameter. I would like to pass these parameters to 3
subsequent queries that use the same dates and division. Currently,
the user must re-enter these parameters 4 times for the macro to
complete processing. This is very cumbersome and leaves much room for
error. How do I save the variables and pass them to each query?

SELECT CMASCP.CPCUS, CMASTR.CU_NME, CMASCP.CPDIV, CMASCP.CP_CID,
CMASCP.CPCDTE, CMASCP.CPCSMN, CMASCP.CPTYP, CMASCP.CPCDET,
CMASCP.CPSEQ
FROM S10BB89B.QS36F.CMASCP CMASCP, S10BB89B.QS36F.CMASTR CMASTR
WHERE CMASCP.CPCUS = CMASTR.CU_CUS AND CMASCP.CPDIV = CMASTR.CU_DIV
AND CMASCP.CPCO = CMASTR.CU_CO AND ((CMASCP.CPCDTE Between ? And ?)
AND (CMASCP.CPDIV=?))

Thanks for any suggestions.
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
Passing Dates criteria in MS Query Jim Thomlinson Excel Discussion (Misc queries) 1 April 1st 08 07:06 PM
Passing Query String into MS Excel napval Excel Programming 0 June 20th 07 10:19 PM
Passing Query String into MS Excel napval Excel Discussion (Misc queries) 0 June 19th 07 06:04 AM
passing parameter to a ms query redf1re Excel Programming 6 February 7th 06 10:39 PM
Passing parameter to a query Dwaine Horton[_3_] Excel Programming 6 April 26th 05 02:24 AM


All times are GMT +1. The time now is 10:25 AM.

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"