Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Parameter Driven Query

Hi,

I'm used to using MS Query to return data to Excel, but there's a whole
stack of queries that I run each month (literally, dozens) where the date
range needs to be changed.

I'm wondering whether I could put the chosen date ranges into an excel
spreadsheet, maybe in the format:

Col 1 Col 2 Col 3 Col 4
sheet query start date end date

....and use VBA to modify the SQL for me.

Alternatively, can the SQL itself be written to request a parameter from a
particular location?

Any ideas? This could be a massive time saver!

Cheers,

Tom.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Parameter Driven Query

I usally start by Recording a macro when I perform a querry. Then I modify
te querry to make it general purpose. if you post the recorded macro I can
make the modification you require.

to start a Record macro from worksheet
1) Tools - Macro - Record New Macro

2) Perform the querry

3) Tools - Macro - Stop Recording




"mr tom" wrote:

Hi,

I'm used to using MS Query to return data to Excel, but there's a whole
stack of queries that I run each month (literally, dozens) where the date
range needs to be changed.

I'm wondering whether I could put the chosen date ranges into an excel
spreadsheet, maybe in the format:

Col 1 Col 2 Col 3 Col 4
sheet query start date end date

...and use VBA to modify the SQL for me.

Alternatively, can the SQL itself be written to request a parameter from a
particular location?

Any ideas? This could be a massive time saver!

Cheers,

Tom.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Parameter Driven Query

Thanks Joel,

I really should have done that earlier. I'd (stupidly) assumed that a
recording macro wouldn't track my activity within MS Query.

I play about with VBA a bit, so now I've got a recorded one to play with, I
can probably work it out from here.

Thanks so much for pointing me in the right direction.

Cheers.

Tom.

"Joel" wrote:

I usally start by Recording a macro when I perform a querry. Then I modify
te querry to make it general purpose. if you post the recorded macro I can
make the modification you require.

to start a Record macro from worksheet
1) Tools - Macro - Record New Macro

2) Perform the querry

3) Tools - Macro - Stop Recording




"mr tom" wrote:

Hi,

I'm used to using MS Query to return data to Excel, but there's a whole
stack of queries that I run each month (literally, dozens) where the date
range needs to be changed.

I'm wondering whether I could put the chosen date ranges into an excel
spreadsheet, maybe in the format:

Col 1 Col 2 Col 3 Col 4
sheet query start date end date

...and use VBA to modify the SQL for me.

Alternatively, can the SQL itself be written to request a parameter from a
particular location?

Any ideas? This could be a massive time saver!

Cheers,

Tom.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Parameter Driven Query

Better to move away from MS Query and code with ADO where you have
parameterized queries and a lot of other useful options.

RBS

"mr tom" <mr-tom at mr-tom.co.uk.(donotspam) wrote in message
...
Hi,

I'm used to using MS Query to return data to Excel, but there's a whole
stack of queries that I run each month (literally, dozens) where the date
range needs to be changed.

I'm wondering whether I could put the chosen date ranges into an excel
spreadsheet, maybe in the format:

Col 1 Col 2 Col 3 Col 4
sheet query start date end date

...and use VBA to modify the SQL for me.

Alternatively, can the SQL itself be written to request a parameter from a
particular location?

Any ideas? This could be a massive time saver!

Cheers,

Tom.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Parameter Driven Query

It probably would be better, but I'm still getting to grips with VBA and SQL.
;)

I'm a project manager (not an IT one) rather than a techie, although I do as
much techie stuff as I can as I don't like to be helpless...

Cheers.

"RB Smissaert" wrote:

Better to move away from MS Query and code with ADO where you have
parameterized queries and a lot of other useful options.

RBS

"mr tom" <mr-tom at mr-tom.co.uk.(donotspam) wrote in message
...
Hi,

I'm used to using MS Query to return data to Excel, but there's a whole
stack of queries that I run each month (literally, dozens) where the date
range needs to be changed.

I'm wondering whether I could put the chosen date ranges into an excel
spreadsheet, maybe in the format:

Col 1 Col 2 Col 3 Col 4
sheet query start date end date

...and use VBA to modify the SQL for me.

Alternatively, can the SQL itself be written to request a parameter from a
particular location?

Any ideas? This could be a massive time saver!

Cheers,

Tom.







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Parameter Driven Query

There really isn't that much to learn there only a few objects, methods and
properties. Then there always is the public.data.ado NG to ask if you get
stuck. MS Query is fine for a quick query from the Excel interface, but if
you
get into anything that goes a bit further you are better of with ADO.

RBS


"mr tom" <mr-tom at mr-tom.co.uk.(donotspam) wrote in message
...
It probably would be better, but I'm still getting to grips with VBA and
SQL.
;)

I'm a project manager (not an IT one) rather than a techie, although I do
as
much techie stuff as I can as I don't like to be helpless...

Cheers.

"RB Smissaert" wrote:

Better to move away from MS Query and code with ADO where you have
parameterized queries and a lot of other useful options.

RBS

"mr tom" <mr-tom at mr-tom.co.uk.(donotspam) wrote in message
...
Hi,

I'm used to using MS Query to return data to Excel, but there's a whole
stack of queries that I run each month (literally, dozens) where the
date
range needs to be changed.

I'm wondering whether I could put the chosen date ranges into an excel
spreadsheet, maybe in the format:

Col 1 Col 2 Col 3 Col 4
sheet query start date end date

...and use VBA to modify the SQL for me.

Alternatively, can the SQL itself be written to request a parameter
from a
particular location?

Any ideas? This could be a massive time saver!

Cheers,

Tom.






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Parameter Driven Query

Thanks. That sounds as if it could be worth thinking about.

I've got someone who does loads in ms query and this could be a good next
step for them.

"RB Smissaert" wrote:

There really isn't that much to learn there only a few objects, methods and
properties. Then there always is the public.data.ado NG to ask if you get
stuck. MS Query is fine for a quick query from the Excel interface, but if
you
get into anything that goes a bit further you are better of with ADO.

RBS


"mr tom" <mr-tom at mr-tom.co.uk.(donotspam) wrote in message
...
It probably would be better, but I'm still getting to grips with VBA and
SQL.
;)

I'm a project manager (not an IT one) rather than a techie, although I do
as
much techie stuff as I can as I don't like to be helpless...

Cheers.

"RB Smissaert" wrote:

Better to move away from MS Query and code with ADO where you have
parameterized queries and a lot of other useful options.

RBS

"mr tom" <mr-tom at mr-tom.co.uk.(donotspam) wrote in message
...
Hi,

I'm used to using MS Query to return data to Excel, but there's a whole
stack of queries that I run each month (literally, dozens) where the
date
range needs to be changed.

I'm wondering whether I could put the chosen date ranges into an excel
spreadsheet, maybe in the format:

Col 1 Col 2 Col 3 Col 4
sheet query start date end date

...and use VBA to modify the SQL for me.

Alternatively, can the SQL itself be written to request a parameter
from a
particular location?

Any ideas? This could be a massive time saver!

Cheers,

Tom.






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Parameter Driven Query

Just a couple of quick questions:
What's the difference between ADO and ADO.NET? - Which do I need for Excel?
Where can I learn (idiot level) about this? Is there a good book or website?

Cheers.

"RB Smissaert" wrote:

There really isn't that much to learn there only a few objects, methods and
properties. Then there always is the public.data.ado NG to ask if you get
stuck. MS Query is fine for a quick query from the Excel interface, but if
you
get into anything that goes a bit further you are better of with ADO.

RBS


"mr tom" <mr-tom at mr-tom.co.uk.(donotspam) wrote in message
...
It probably would be better, but I'm still getting to grips with VBA and
SQL.
;)

I'm a project manager (not an IT one) rather than a techie, although I do
as
much techie stuff as I can as I don't like to be helpless...

Cheers.

"RB Smissaert" wrote:

Better to move away from MS Query and code with ADO where you have
parameterized queries and a lot of other useful options.

RBS

"mr tom" <mr-tom at mr-tom.co.uk.(donotspam) wrote in message
...
Hi,

I'm used to using MS Query to return data to Excel, but there's a whole
stack of queries that I run each month (literally, dozens) where the
date
range needs to be changed.

I'm wondering whether I could put the chosen date ranges into an excel
spreadsheet, maybe in the format:

Col 1 Col 2 Col 3 Col 4
sheet query start date end date

...and use VBA to modify the SQL for me.

Alternatively, can the SQL itself be written to request a parameter
from a
particular location?

Any ideas? This could be a massive time saver!

Cheers,

Tom.






  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Parameter Driven Query

ADO.NET is for the dotnet languages like C# etc. so you want ADO.
Plenty of good tutorials on the web to get started. Just Google on
something like ADO tutorial.

RBS

On 7 Jan, 14:51, mr tom <mr-tom at mr-tom.co.uk.(donotspam) wrote:
Just a couple of quick questions:
What's the difference between ADO and ADO.NET? - Which do I need for Excel?
Where can I learn (idiot level) about this? *Is there a good book or website?

Cheers.



"RB Smissaert" wrote:
There really isn't that much to *learn there only a few objects, methods and
properties. Then there always is the public.data.ado NG to ask if you get
stuck. MS Query is fine for a quick query from the Excel interface, but if
you
get into anything that goes a bit further you are better of with ADO.


RBS


"mr tom" <mr-tom at mr-tom.co.uk.(donotspam) wrote in message
...
It probably would be better, but I'm still getting to grips with VBA and
SQL.
;)


I'm a project manager (not an IT one) rather than a techie, although I do
as
much techie stuff as I can as I don't like to be helpless...


Cheers.


"RB Smissaert" wrote:


Better to move away from MS Query and code with ADO where you have
parameterized queries and a lot of other useful options.


RBS


"mr tom" <mr-tom at mr-tom.co.uk.(donotspam) wrote in message
...
Hi,


I'm used to using MS Query to return data to Excel, but there's a whole
stack of queries that I run each month (literally, dozens) where the
date
range needs to be changed.


I'm wondering whether I could put the chosen date ranges into an excel
spreadsheet, maybe in the format:


Col 1 * Col 2 * Col 3 * * * *Col 4
sheet *query *start date *end date


...and use VBA to modify the SQL for me.


Alternatively, can the SQL itself be written to request a parameter
from a
particular location?


Any ideas? *This could be a massive time saver!


Cheers,


Tom.- Hide quoted text -


- Show quoted text -


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default Parameter Driven Query

MS Query is set up to use parameters easily - you can use square
brackets with a space in between in the interface (not the wizard, the
advanced interface) for the criteria values. When you run or refresh
the query Excel will display a dialog where you can choose to use a
range (cell)/ formula or value for the parameter and whether to always
use this range/formula/value for this parameter. I've used this
feature with input boxes/userforms extensively with success.

If you're editing the SQL statement directly, you can use a question
mark for the parameter value and Excel will behave as described. (The
ui is just writing SQL based on your input anyhow)

You may run into some trouble trying to record complex queries (using
the advanced interface) as you write them. (can't record) You can work
around this by writing the query then record refreshing it.

Cliff Edwards


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Parameter Driven Query

Thanks Cliff. That sounds like the best answer yet.

Tom.

"ward376" wrote:

MS Query is set up to use parameters easily - you can use square
brackets with a space in between in the interface (not the wizard, the
advanced interface) for the criteria values. When you run or refresh
the query Excel will display a dialog where you can choose to use a
range (cell)/ formula or value for the parameter and whether to always
use this range/formula/value for this parameter. I've used this
feature with input boxes/userforms extensively with success.

If you're editing the SQL statement directly, you can use a question
mark for the parameter value and Excel will behave as described. (The
ui is just writing SQL based on your input anyhow)

You may run into some trouble trying to record complex queries (using
the advanced interface) as you write them. (can't record) You can work
around this by writing the query then record refreshing it.

Cliff Edwards

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
Excel Web Query for Java Applet driven data website mingInv Excel Discussion (Misc queries) 1 August 25th 10 06:14 AM
Convert hard coded query criteria to Parameter Query Melanie[_2_] Excel Discussion (Misc queries) 0 July 15th 08 09:59 PM
How to choose if I use a parameter or not in a parameter query Arnaud Excel Discussion (Misc queries) 0 March 8th 07 01:19 PM
parameter and macro driven pivot table filter? Ryan Hartnett Excel Programming 0 October 25th 06 09:26 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Excel Discussion (Misc queries) 1 December 13th 04 07:54 PM


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

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

About Us

"It's about Microsoft Excel"