L
Les Gombart
I have one table called PRICING and 21 other tables that I link separately to
this table to create a SELECT query. In other words, instead of creating 21
SELECT queries, I want to be able to use variables within VBA to change the
table name that links to the pricing table (fileds within all 21 other tables
are named exactly the same).
I have been trying to create a VBA procedure to run the SQL statement to
temporarily create the SELECT query.
I undertsnad that that I can use the DoCmd.RunSQL function, but cannot get
the SQL statement right.
When I copy and paste the SQL statment from an exisiting query, I still get
errors.
The SQL statement that will eventually replace with variables is as follows:
SELECT pricing.Hierarchy AS base_Hierarchy, pricing.Material, pricing.Base,
natcat.[Trade %], (([Base]*[Trade %])) AS Net1, natcat.[EDLP %],
([Base]-[net1])*[EDLP %] AS Net2, [Base]-[Net1]-[NET2] AS net
FROM pricing INNER JOIN natcat ON pricing.Hierarchy = natcat.hierarchy;
When I try "clean up" the code to:
strSql = "SELECT pricing.Hierarchy AS base_Hierarchy, pricing.Material,
pricing.Base, natcat.[Trade %], (([Base]*[Trade %])) AS Net1, natcat.[EDLP
%], ([Base]-[net1])*[EDLP %] AS Net2, [Base]-[Net1]-[NET2] AS net " & vbCrLf
& _
"FROM pricing INNER JOIN natcat ON pricing.Hierarchy = natcat.hierarchy;"
I am still not successful... HELP PLEASE
this table to create a SELECT query. In other words, instead of creating 21
SELECT queries, I want to be able to use variables within VBA to change the
table name that links to the pricing table (fileds within all 21 other tables
are named exactly the same).
I have been trying to create a VBA procedure to run the SQL statement to
temporarily create the SELECT query.
I undertsnad that that I can use the DoCmd.RunSQL function, but cannot get
the SQL statement right.
When I copy and paste the SQL statment from an exisiting query, I still get
errors.
The SQL statement that will eventually replace with variables is as follows:
SELECT pricing.Hierarchy AS base_Hierarchy, pricing.Material, pricing.Base,
natcat.[Trade %], (([Base]*[Trade %])) AS Net1, natcat.[EDLP %],
([Base]-[net1])*[EDLP %] AS Net2, [Base]-[Net1]-[NET2] AS net
FROM pricing INNER JOIN natcat ON pricing.Hierarchy = natcat.hierarchy;
When I try "clean up" the code to:
strSql = "SELECT pricing.Hierarchy AS base_Hierarchy, pricing.Material,
pricing.Base, natcat.[Trade %], (([Base]*[Trade %])) AS Net1, natcat.[EDLP
%], ([Base]-[net1])*[EDLP %] AS Net2, [Base]-[Net1]-[NET2] AS net " & vbCrLf
& _
"FROM pricing INNER JOIN natcat ON pricing.Hierarchy = natcat.hierarchy;"
I am still not successful... HELP PLEASE