I used Allen Brownes code to make an Inventory example where the "On Hand" is calculated. I then wanted to tried and make the Invoice side of it work for Products instead of just parts. (Products are assemblies of parts)
So I wrote a query to parse the part qty per product and the product qty per Invoice then multiply them together in an expression "LIPP1" (see code) I then went to SQL mode and copied the SQL statement. Then went to the 'Get the quantity used since then.' section of his code and replaced his strSQL with mine. I then tried to used his syntax for Sum and criteria to atempt to get the total parts used. I get runtime error 3075 with "missing operator". Could anyone tell me if they see the problem or even if I'm going about this the right way? I know if I can Sum the LIPP1 parameter of my query it works out mathimatically. I just can't get it to work in code.
strSQL = "SELECT Sum (tblInvoice.InvoiceID, tblInvoiceDetail.ProductID, tblInvoiceDetail.Quantity " & _
" AS tblInvoiceDetail_Quantity, tblProductDetail.PartID, tblProductDetail.Quantity AS tblProductDetail_Quantity, " & _
" [tblInvoiceDetail_Quantity]*[tblProductDetail_Quantity] AS LIPP1) As QuantityUsed " & _
" FROM (tblProduct INNER JOIN tblProductDetail ON tblProduct.[ProductID] = tblProductDetail.[ProductID]) INNER JOIN " & _
" (tblInvoice INNER JOIN tblInvoiceDetail ON tblInvoice.[InvoiceID] = tblInvoiceDetail.[InvoiceID]) ON tblProduct.[ProductID] = tblInvoiceDetail.[ProductID] " & _
" WHERE ((tblProductDetail.PartID)= " & lngPart & ")"
Set rs = db.OpenRecordset(strSQL) Hangs on this line, but problem is in the SQL statement above.