When I use this Update query in Access it updates the fields in the table:
Code:
UPDATE QryCostDiff LEFT JOIN TblActCosts ON QryCostDiff.CON_ID = TblActCosts.ActCON_ID SET TblActCosts.ActGNDTVL = [Forms]![FrmCostDifferences].[ActGNDTVL], TblActCosts.ActTDYStart = [Forms]![FrmCostDifferences].[ActTDYStart], TblActCosts.ActTDYStop = [Forms]![FrmCostDifferences].[ActTDYStop], TblActCosts.ActPDLodge = [Forms]![FrmCostDifferences].[ActPDLodge], TblActCosts.ActLodgeTTL = [Forms]![FrmCostDifferences].[ActLodgeTTL], TblActCosts.ActLodgeTax = [Forms]![FrmCostDifferences].[ActLodgeTax], TblActCosts.ActLodgeWTaxTTL = [Forms]![FrmCostDifferences].[ActLodgeWTaxTTL], TblActCosts.ActPDMeal = [Forms]![FrmCostDifferences]![ActPDMeal], TblActCosts.ActMealTTL = [Forms]![FrmCostDifferences].[ActMealTTL], TblActCosts.ActRent_Type = [Forms]![FrmCostDifferences].[ActRent_Type], TblActCosts.ActRCost = [Forms]![FrmCostDifferences].[ActRCost], TblActCosts.ActFuel = [Forms]![FrmCostDifferences].[ActFuel], TblActCosts.ActRentTTL = [Forms]![FrmCostDifferences]![ActRentTTL], TblActCosts.ActRentTaxTTL = [Forms]![FrmCostDifferences].[ActRentTaxTTL], TblActCosts.ActRentTtlWTax = [Forms]![FrmCostDifferences].[ActRentTtlWTax], TblActCosts.ActBkFee = [Forms]![FrmCostDifferences].[ActBkFee], TblActCosts.ActH2AIRTTL = [Forms]![FrmCostDifferences].[ActH2AIRTTL], TblActCosts.ActAirPark = [Forms]![FrmCostDifferences].[ActAirPark], TblActCosts.ActCarrier = [Forms]![FrmCostDifferences].[ActCarrier], TblActCosts.ActAirfare = [Forms]![FrmCostDifferences].[ActAirfare], TblActCosts.ActBagNum = [Forms]![FrmCostDifferences].[ActBagNum], TblActCosts.ActBagCost = [Forms]![FrmCostDifferences].[ActBagCost], TblActCosts.ActExcessBagCost = [Forms]![FrmCostDifferences].[ActExcessBagCost], TblActCosts.ActBag = [Forms]![FrmCostDifferences].[ActBag], TblActCosts.ActTolls = [Forms]![FrmCostDifferences].[ActTolls], TblActCosts.ActTvlTTL = [Forms]![FrmCostDifferences].[ActTvlTTL], TblActCosts.ActOtherTTL = [Forms]![FrmCostDifferences].[ActOtherTTL], TblActCosts.ActLegTTL = [Forms]![FrmCostDifferences].[ActLegTTL], TblActCosts.ActTTLEWWHrs = [Forms]![FrmCostDifferences].[ActTTLEWWHrs], TblActCosts.ActODCCost = [Forms]![FrmCostDifferences].[ActODCCost], TblActCosts.ActTitels = [Forms]![FrmCostDifferences].[ActTitels]
WHERE (((TblActCosts.ActCON_ID)=[Forms]![FrmCostDifferences].[ActCON_ID]));
Yet when I put this in VBA so that I don't have to select and open a query and it stays hidden
Code:
CurrentDb.Execute "UPDATE QryCostDiff LEFT JOIN TblActCosts ON QryCostDiff.CON_ID = TblActCosts.ActCON_ID SET " & _
"TblActCosts.ActGNDTVL = [Forms]![FrmCostDifferences].[ActGNDTVL], TblActCosts.ActTDYStart = [Forms]![FrmCostDifferences].[ActTDYStart], " & _
"TblActCosts.ActTDYStop = [Forms]![FrmCostDifferences].[ActTDYStop], TblActCosts.ActPDLodge = [Forms]![FrmCostDifferences].[ActPDLodge], " & _
"TblActCosts.ActLodgeTTL = [Forms]![FrmCostDifferences].[ActLodgeTTL], TblActCosts.ActLodgeTax = [Forms]![FrmCostDifferences].[ActLodgeTax], " & _
"TblActCosts.ActLodgeWTaxTTL = [Forms]![FrmCostDifferences].[ActLodgeWTaxTTL], TblActCosts.ActPDMeal = [Forms]![FrmCostDifferences]![ActPDMeal], " & _
"TblActCosts.ActMealTTL = [Forms]![FrmCostDifferences].[ActMealTTL], TblActCosts.ActRent_Type = [Forms]![FrmCostDifferences].[ActRent_Type], " & _
"TblActCosts.ActRCost = [Forms]![FrmCostDifferences].[ActRCost], TblActCosts.ActFuel = [Forms]![FrmCostDifferences].[ActFuel], " & _
"TblActCosts.ActRentTTL = [Forms]![FrmCostDifferences]![ActRentTTL], TblActCosts.ActRentTaxTTL = [Forms]![FrmCostDifferences].[ActRentTaxTTL], " & _
"TblActCosts.ActRentTtlWTax = [Forms]![FrmCostDifferences].[ActRentTtlWTax], TblActCosts.ActBkFee = [Forms]![FrmCostDifferences].[ActBkFee], " & _
"TblActCosts.ActH2AIRTTL = [Forms]![FrmCostDifferences].[ActH2AIRTTL], TblActCosts.ActAirPark = [Forms]![FrmCostDifferences].[ActAirPark], " & _
"TblActCosts.ActCarrier = [Forms]![FrmCostDifferences].[ActCarrier], TblActCosts.ActAirfare = [Forms]![FrmCostDifferences].[ActAirfare], " & _
"TblActCosts.ActBagNum = [Forms]![FrmCostDifferences].[ActBagNum], TblActCosts.ActBagCost = [Forms]![FrmCostDifferences].[ActBagCost], " & _
"TblActCosts.ActExcessBagCost = [Forms]![FrmCostDifferences].[ActExcessBagCost], TblActCosts.ActBag = [Forms]![FrmCostDifferences].[ActBag], " & _
"TblActCosts.ActTolls = [Forms]![FrmCostDifferences].[ActTolls], TblActCosts.ActTvlTTL = [Forms]![FrmCostDifferences].[ActTvlTTL], " & _
"TblActCosts.ActOtherTTL = [Forms]![FrmCostDifferences].[ActOtherTTL], TblActCosts.ActLegTTL = [Forms]![FrmCostDifferences].[ActLegTTL], " & _
"TblActCosts.ActTTLEWWHrs = [Forms]![FrmCostDifferences].[ActTTLEWWHrs], TblActCosts.ActODCCost = [Forms]![FrmCostDifferences].[ActODCCost], " & _
"TblActCosts.ActTitels = [Forms]![FrmCostDifferences].[ActTitels] " & _
"WHERE (((TblActCosts.ActCON_ID)=[Forms]![FrmCostDifferences].[ActCON_ID]));"
I get "Runtime Error '3061': Too few parameters, Expected 32"
ActCON_ID is numerical
I changed "WHERE (((TblActCosts.ActCON_ID)=[Forms]![FrmCostDifferences].[ActCON_ID]));" to "WHERE TblActCosts.ActCON_ID= """ & [Forms]![FrmCostDifferences].[ActCON_ID] & ";"""
then I get "Runtime Error '3061': Too few parameters, Expected 31"
Am I getting the concatenation incorrect?