R
Regan via AccessMonster.com
Hi, i'm wondering why my insert query isn't working. if i take away the
'INSERT INTO' bit, it selects the right records to insert. But when i put
INSERT INTO it comes up with
'Characters found after SQL statement' i tried other things like taking away
the ; . but i can't seem to get it to work
here is the SQL
INSERT INTO tblinvexpdetails(InvoiceID, Expense, Charge)
SELECT "11" AS InvoiceID,
tblExpenses.Expense AS Expense,
Sum(tblexpenseLog.Quantity*tblexpenses.chargeout) AS total
FROM tblExpenses INNER JOIN tblExpenseLog ON tblExpenses.ExpenseID =
tblExpenseLog.ExpenseID
WHERE tblexpenselog.fileID=Forms!frmcreateInv!txtFileID
AND tblexpenselog.expensedate>= Forms!frmcreateInv!txtDateFrom
AND tblexpenselog.expensedate<= Forms!frmcreateInv!txtDateTo
GROUP BY tblexpenses.Expense;
UNION
SELECT "11" AS InvoiceID,
"Transport" AS Expense,
Sum(tbltravelLog.km*TTKP.TravelPrice) AS Total
FROM tblTravelLog INNER JOIN TblTravelKmPricing AS TTKP ON tblTravelLog.
TravelPricingID = TTKP.TravelPriceID
WHERE (((tblTravelLog.FileID)= [Forms]![frmcreateInv]![txtFileID])
AND ((tblTravelLog.TravelDate)>= [Forms]![frmcreateInv]![txtDateFrom]
AND (tblTravelLog.TravelDate)<= [Forms]![frmcreateInv]![txtDateTo]));
Thanks for your help in advance
Cheers
'INSERT INTO' bit, it selects the right records to insert. But when i put
INSERT INTO it comes up with
'Characters found after SQL statement' i tried other things like taking away
the ; . but i can't seem to get it to work
here is the SQL
INSERT INTO tblinvexpdetails(InvoiceID, Expense, Charge)
SELECT "11" AS InvoiceID,
tblExpenses.Expense AS Expense,
Sum(tblexpenseLog.Quantity*tblexpenses.chargeout) AS total
FROM tblExpenses INNER JOIN tblExpenseLog ON tblExpenses.ExpenseID =
tblExpenseLog.ExpenseID
WHERE tblexpenselog.fileID=Forms!frmcreateInv!txtFileID
AND tblexpenselog.expensedate>= Forms!frmcreateInv!txtDateFrom
AND tblexpenselog.expensedate<= Forms!frmcreateInv!txtDateTo
GROUP BY tblexpenses.Expense;
UNION
SELECT "11" AS InvoiceID,
"Transport" AS Expense,
Sum(tbltravelLog.km*TTKP.TravelPrice) AS Total
FROM tblTravelLog INNER JOIN TblTravelKmPricing AS TTKP ON tblTravelLog.
TravelPricingID = TTKP.TravelPriceID
WHERE (((tblTravelLog.FileID)= [Forms]![frmcreateInv]![txtFileID])
AND ((tblTravelLog.TravelDate)>= [Forms]![frmcreateInv]![txtDateFrom]
AND (tblTravelLog.TravelDate)<= [Forms]![frmcreateInv]![txtDateTo]));
Thanks for your help in advance
Cheers