Hi,
I have 2 tables
Branches
BranchId, RegionId, City Name, Population, A, B, C, D, E, F, G
CityMarket
CityMarketId, BranchId, Market Name, A, B, C, D, E, F, G
I need to get the totals of A, B, C,... by Branch Id from City Market and input it in the table Branches.
All this is done by a button in a form
I have written this but is giving me a compile error:
DoCmd.RunSQL ("INSERT INTO Branches [A Outlets], [B Outlets], [C & D Outlets], [Wholesale General], [Wholesale Semi/Conf], [Catering], [Table Top], [Others]) & _ “SELECT CityMarket.BranchId, Sum(CityMarket.[A Outlets]) AS [SumOfA Outlets], Sum(CityMarket.[B Outlets]) AS [SumOfB Outlets], Sum(CityMarket.[C & D Outlets]) AS [SumOfC & D Outlets], Sum(CityMarket.[Wholesale General]) AS [SumOfWholesale General], Sum(CityMarket.[Wholesale Semi/Conf]) AS [SumOfWholesale Semi/Conf], Sum(CityMarket.Catering) AS SumOfCatering, Sum(CityMarket.[Table Top]) AS [SumOfTable Top], Sum(CityMarket.Others) AS SumOfOthers
FROM CityMarket
GROUP BY CityMarket.BranchId
Any ideas why?
I have 2 tables
Branches
BranchId, RegionId, City Name, Population, A, B, C, D, E, F, G
CityMarket
CityMarketId, BranchId, Market Name, A, B, C, D, E, F, G
I need to get the totals of A, B, C,... by Branch Id from City Market and input it in the table Branches.
All this is done by a button in a form
I have written this but is giving me a compile error:
DoCmd.RunSQL ("INSERT INTO Branches [A Outlets], [B Outlets], [C & D Outlets], [Wholesale General], [Wholesale Semi/Conf], [Catering], [Table Top], [Others]) & _ “SELECT CityMarket.BranchId, Sum(CityMarket.[A Outlets]) AS [SumOfA Outlets], Sum(CityMarket.[B Outlets]) AS [SumOfB Outlets], Sum(CityMarket.[C & D Outlets]) AS [SumOfC & D Outlets], Sum(CityMarket.[Wholesale General]) AS [SumOfWholesale General], Sum(CityMarket.[Wholesale Semi/Conf]) AS [SumOfWholesale Semi/Conf], Sum(CityMarket.Catering) AS SumOfCatering, Sum(CityMarket.[Table Top]) AS [SumOfTable Top], Sum(CityMarket.Others) AS SumOfOthers
FROM CityMarket
GROUP BY CityMarket.BranchId
Any ideas why?