View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
AccessHelp AccessHelp is offline
external usenet poster
 
Posts: 213
Default Connecting Questions on Querytables

Hello all,

I have two querytables in my Excel worksheet "Sheet 1" that connect to an
Access database. Since I have two querytables, I only want to run one of the
two. So I use the following code for my command button:

Worksheets("Sheet 1").QueryTables(1).Refresh

Somehow, when I click on the button, the query would not run. In order to
run that query, I have to go into DataImport External DataEdit Query to
run. What I have been noticing is after I go into Edit Query, subsequent
clickings on the button will run the query, without going into Edit Query.
When I close the file and open it next time, I will again have problem
running the query when I click on the button, unless I go into Edit Query.

Does anyone know what causes to happen? Do I have the code correct? How
can I fix that problem? Is there a way to find out what querytable number is
for the query that I want to run?

Thanks.