Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saved Query vs SQL

Status
Not open for further replies.

Loomah

Technical User
Mar 4, 2002
1,911
IE
Hi everyone!

This is kind of a folow up question to thread thread68-506187.

I'm developing part of a system to bring data into Excel from an accounts package that's built on Fox Pro. I'm also quite new to ('real world') data queries and VERY new to SQL!

So, I had two choices either record the SQL into the routine or create a query and call it from the routine. The SQL idea produced ridiculous results when I tried to record it particularly when trying to join the tables. Most of the SQL didn't record, and I'm not sure enough to write it into the VBE directly.

So, I have a query that does the job using

Code:
Set myQT = Worksheets("DataImport").QueryTables.Add(Connection:= _
"FINDER;M:\Accounts\Janis\Opera stuff\MB_TestArea\MPC_DataLoad_v1.dqy", _
Destination:=Range("DataStart"))

etc......etc....etc.....

The question is, is there another way to do this (run a saved query) without 'Adding' each time as I'm left with a ton of query tables. I'm currently getting around this, rather clumsily, by finding them and deleting the old ones before running the query.

Any help or general pointers appreciated.

;-) If a man says something and there are no women there to hear him, is he still wrong? [ponder]
 
Skip
It was that thread that got me thinking and I'm following up on!!

In essence I had the desired result but I need to know if I'm missing something more elegant as I'm returning to my days of cracking a nut with a sledgehammer!

The SQL's too cumbersome for ME to handle in vba. Didn't like me trying to record 'FROM table1 LEFT JOIN table2 ON table1.acct+table1.cntr=table2accnt'. I don't even fully understand this I just know it's necessary!!

Saved Query is nice and tidy to edit (if necessary) and call from vba but I don't really want to add a query table every time I run the query. Is there another way of running a saved query? Using the code you posted before??

I seem to be missing a point somewhere!

[ponder] If a man says something and there are no women there to hear him, is he still wrong? [ponder]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top