Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default auto Refresh MS Query SQL Server

I have a MS Query to retrieve data from SQL server database through ODBC
Connection

My user needs to right click to refresh data every time.

Is it possible to write some code to refresh the MS Query when open the
spreadsheet?

Also, May I pass parameter from spreadsheet?

Any information is great appreciated,


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default auto Refresh MS Query SQL Server

Yes, both those abilities are built into the querytable in Excel so it is not
hard to set it up: Place the cursor on any cell in your querytable results
list, then right-click and select "Data Range Properties." Make sure save
query definition and save password (if your database has a password) are
checked off and then (about halfway down in the dialog box) check off the box
that says "Refresh data on file open." If you do this you can also choose to
"Remove external data from worksheet before saving" which minimizes the file
size but also means that the query data is not saved and must be refreshed
next time the file is open to be seen - if there were any problem accessing
the database when the file opened the list would be blank!

To pass a parameter from the spreadsheet, go into MSQuery and set up your
criteria with the parameter in square braces, e.g. [Name]='K Dales'. Then
close Query and return the data to Excel. It will ask you to supply the
value for [Name]; you can supply a sample value or even just leave that blank
for now. Then, when the query results are displayed, go back to a cell
within the query and right-click again; this time choose "Parameters..." The
dialog will list all parameters you asked for (e.g. Name, in the example I
gave) and then will ask how you want to supply the parameter; choose the 3rd
choice, "Get the value from the following cell:" and specify the worksheet
cell you want to use for the parameter (or, alternately, you can prompt the
user at the time the query runs - 1st choice in the parameters dialog).

--
- K Dales


"Souris" wrote:

I have a MS Query to retrieve data from SQL server database through ODBC
Connection

My user needs to right click to refresh data every time.

Is it possible to write some code to refresh the MS Query when open the
spreadsheet?

Also, May I pass parameter from spreadsheet?

Any information is great appreciated,


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default auto Refresh MS Query SQL Server

Thanks for your information,

I got refresh one.

About pass parameter, my stored procedures are not in my select list when I
use MS Query to access my SQL server.

I tried to use MS Access to access SQL server stored procedure.

My Excel spreadsheet to access a query to SQL server query.

My MS Access query must have paramter like
EXEC MySP @MyParam = 'Name'

My parameter celll must match the parameter in the access query.
It makes me need to go to change paramter all the time.

Can you please let me know where I did wrong?
Thanks again millions,



"K Dales" wrote:

Yes, both those abilities are built into the querytable in Excel so it is not
hard to set it up: Place the cursor on any cell in your querytable results
list, then right-click and select "Data Range Properties." Make sure save
query definition and save password (if your database has a password) are
checked off and then (about halfway down in the dialog box) check off the box
that says "Refresh data on file open." If you do this you can also choose to
"Remove external data from worksheet before saving" which minimizes the file
size but also means that the query data is not saved and must be refreshed
next time the file is open to be seen - if there were any problem accessing
the database when the file opened the list would be blank!

To pass a parameter from the spreadsheet, go into MSQuery and set up your
criteria with the parameter in square braces, e.g. [Name]='K Dales'. Then
close Query and return the data to Excel. It will ask you to supply the
value for [Name]; you can supply a sample value or even just leave that blank
for now. Then, when the query results are displayed, go back to a cell
within the query and right-click again; this time choose "Parameters..." The
dialog will list all parameters you asked for (e.g. Name, in the example I
gave) and then will ask how you want to supply the parameter; choose the 3rd
choice, "Get the value from the following cell:" and specify the worksheet
cell you want to use for the parameter (or, alternately, you can prompt the
user at the time the query runs - 1st choice in the parameters dialog).

--
- K Dales


"Souris" wrote:

I have a MS Query to retrieve data from SQL server database through ODBC
Connection

My user needs to right click to refresh data every time.

Is it possible to write some code to refresh the MS Query when open the
spreadsheet?

Also, May I pass parameter from spreadsheet?

Any information is great appreciated,


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default auto Refresh MS Query SQL Server

Thanks for the indformation,
I got it works.

Thanks millions,

"Souris" wrote:

Thanks for your information,

I got refresh one.

About pass parameter, my stored procedures are not in my select list when I
use MS Query to access my SQL server.

I tried to use MS Access to access SQL server stored procedure.

My Excel spreadsheet to access a query to SQL server query.

My MS Access query must have paramter like
EXEC MySP @MyParam = 'Name'

My parameter celll must match the parameter in the access query.
It makes me need to go to change paramter all the time.

Can you please let me know where I did wrong?
Thanks again millions,



"K Dales" wrote:

Yes, both those abilities are built into the querytable in Excel so it is not
hard to set it up: Place the cursor on any cell in your querytable results
list, then right-click and select "Data Range Properties." Make sure save
query definition and save password (if your database has a password) are
checked off and then (about halfway down in the dialog box) check off the box
that says "Refresh data on file open." If you do this you can also choose to
"Remove external data from worksheet before saving" which minimizes the file
size but also means that the query data is not saved and must be refreshed
next time the file is open to be seen - if there were any problem accessing
the database when the file opened the list would be blank!

To pass a parameter from the spreadsheet, go into MSQuery and set up your
criteria with the parameter in square braces, e.g. [Name]='K Dales'. Then
close Query and return the data to Excel. It will ask you to supply the
value for [Name]; you can supply a sample value or even just leave that blank
for now. Then, when the query results are displayed, go back to a cell
within the query and right-click again; this time choose "Parameters..." The
dialog will list all parameters you asked for (e.g. Name, in the example I
gave) and then will ask how you want to supply the parameter; choose the 3rd
choice, "Get the value from the following cell:" and specify the worksheet
cell you want to use for the parameter (or, alternately, you can prompt the
user at the time the query runs - 1st choice in the parameters dialog).

--
- K Dales


"Souris" wrote:

I have a MS Query to retrieve data from SQL server database through ODBC
Connection

My user needs to right click to refresh data every time.

Is it possible to write some code to refresh the MS Query when open the
spreadsheet?

Also, May I pass parameter from spreadsheet?

Any information is great appreciated,


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
Unable to open after auto refresh(Query) Irmann Excel Discussion (Misc queries) 0 January 8th 08 06:33 AM
Web Query Auto Refresh sjgillum Excel Worksheet Functions 2 December 6th 07 12:23 PM
How do you avoid window that prompts to enable auto query refresh Peter_EZEM Excel Discussion (Misc queries) 3 January 23rd 06 07:17 PM
How do I get a web query to auto-refresh before a pivot table aut. Conniemm Excel Discussion (Misc queries) 0 December 8th 04 06:49 PM
Timing of automatic query refresh and macro pivot table refresh dutty Excel Programming 2 December 1st 04 07:19 PM


All times are GMT +1. The time now is 04:59 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"