firefly2k8
Registered User.
- Local time
- Today, 04:29
- Joined
- Nov 18, 2010
- Messages
- 48
I have a query which works fine if you enter and run it from the Access query window.
However one element of it is variable so I want to run this from within vba.
It is a select query that creates a neat two column table from a range of different tables etc.
I tried do:
strSQL = "SELECT..."
DoCmd.RunSQL strSQL
But this is rejected with an error.
So what I want is to run the query and have it create a table called "Spot_Pairs_Query" which i can then refer to with:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Spot_Pairs_Query", filepath, True, "SpotDataDrop"
I suspect I need SELECT INTO <new table> FROM... , but i cant get this working with my query.
My full query is:
However one element of it is variable so I want to run this from within vba.
It is a select query that creates a neat two column table from a range of different tables etc.
I tried do:
strSQL = "SELECT..."
DoCmd.RunSQL strSQL
But this is rejected with an error.
So what I want is to run the query and have it create a table called "Spot_Pairs_Query" which i can then refer to with:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Spot_Pairs_Query", filepath, True, "SpotDataDrop"
I suspect I need SELECT INTO <new table> FROM... , but i cant get this working with my query.
My full query is:
Code:
SELECT [Trade Date], [Currency Pair] FROM [SE2 Project Table] WHERE Not [Currency Pair] Is Null And [Currency Pair]<>'' And [Type Forward/Spot] = 'Spot' and [Project ID] = 47 UNION SELECT [Trade Date], [Cross Pair] FROM [SE2 Project Table] WHERE Not [Cross Pair] Is Null And [Cross Pair] <> " And [Project ID] = 47 UNION SELECT [Trade Date], [Buy to Base Pair] FROM [SE2 Project Table] WHERE Not [Buy to Base Pair] Is Null And [Buy to Base Pair]<>" and [Project ID] = 47;