I have looked in many books and performed numerous internet searches on how to write queries in VBA. I have not been able to successfully manipulate any of the examples nor could I debug the program code appropriately. When I use the examples for differnt types of queries, the result is the same (unusable VBA code).
A couple of SQL code examples of the different query types in my database are pasted below.
Can someone please translate each sample SQL code into the correct VBA code. Any help will be greatly appreciated. Let me know if you need any additional information.
Select Query:
SELECT Merge.Item AS LineItem, Sum(Merge.DebitMg) AS Spent
FROM Merge
GROUP BY Merge.Item;
Update Query:
UPDATE ChargeType SET ChargeType.CStart = [Enter the Contract Start Date:], ChargeType.Cend = [Enter the Contract End Date:]
WHERE (((ChargeType.Pcode)=[Enter Program Code (Example BI4)]));
Make Table Query: It would be particularly helpful, if the Table can continue to be hidden. When I run this code in SQL, it unhides the table. I am not sure how to indicate "Hide" in the properties of the code.
SELECT [Calculate Spent Calc by Month].LineItem, [Calculate Spent Calc by Month].MthSpent, MonthName([SpentMon],True) & " " & [SpentYr] AS SpntDate INTO MthSpent
FROM [Calculate Spent Calc by Month];
Union Query:
SELECT LINE1.* FROM [LINE1] WHERE [Item] <> " "
UNION
SELECT LINE2.* FROM [LINE2] WHERE [Item] <> " "
UNION
SELECT LINE3.* FROM [LINE3] WHERE [Item] <> " "
UNION
SELECT LINE4.* FROM [LINE4] WHERE [Item] <> " "
UNION
SELECT LINE5.* FROM [LINE5] WHERE [Item] <> " "
UNION
SELECT LINE6.* FROM [LINE6] WHERE [Item] <> " "
UNION SELECT LINE7.* FROM [LINE7] WHERE [Item] <> " ";
A couple of SQL code examples of the different query types in my database are pasted below.
Can someone please translate each sample SQL code into the correct VBA code. Any help will be greatly appreciated. Let me know if you need any additional information.
Select Query:
SELECT Merge.Item AS LineItem, Sum(Merge.DebitMg) AS Spent
FROM Merge
GROUP BY Merge.Item;
Update Query:
UPDATE ChargeType SET ChargeType.CStart = [Enter the Contract Start Date:], ChargeType.Cend = [Enter the Contract End Date:]
WHERE (((ChargeType.Pcode)=[Enter Program Code (Example BI4)]));
Make Table Query: It would be particularly helpful, if the Table can continue to be hidden. When I run this code in SQL, it unhides the table. I am not sure how to indicate "Hide" in the properties of the code.
SELECT [Calculate Spent Calc by Month].LineItem, [Calculate Spent Calc by Month].MthSpent, MonthName([SpentMon],True) & " " & [SpentYr] AS SpntDate INTO MthSpent
FROM [Calculate Spent Calc by Month];
Union Query:
SELECT LINE1.* FROM [LINE1] WHERE [Item] <> " "
UNION
SELECT LINE2.* FROM [LINE2] WHERE [Item] <> " "
UNION
SELECT LINE3.* FROM [LINE3] WHERE [Item] <> " "
UNION
SELECT LINE4.* FROM [LINE4] WHERE [Item] <> " "
UNION
SELECT LINE5.* FROM [LINE5] WHERE [Item] <> " "
UNION
SELECT LINE6.* FROM [LINE6] WHERE [Item] <> " "
UNION SELECT LINE7.* FROM [LINE7] WHERE [Item] <> " ";