My apologies.... I don't have enough time to learn how your tool works.
I would start by fixing the tables: removing lookup fields, correct field names (no reserved words), etc.
Why does table "MonthlyQ" have the PK field (ID) as a GUID instead of an Autonumber???
In the formula, there is a variable "Counter", but I can't see where it is ever initialized.
For the formula, I would get the SELECT statement correct first, then get the insert working.
Code:
SELECT MonthlyQ.CategoryID, MonthlyQ.ProductID, Sum(([MonthlyQ].[Qty])*30/((90)-[DayOFS])) AS AMC,
" & txtPeriod & " AS Mnth, last(StockOnHand) as SOH, VenClassID, first(UnitPrice) as UnitPrc
FROM MonthlyQ
WHERE ((((([MonthlyQ].[Qty])*30/((90)-[DayOFS]))) Is Not Null) AND ((MonthlyQ.Date)
Between #" & LastDayInMonth(DateAdd("M", counter * -1, lastQMonthDate)) & "# And #" & LastDayInMonth(DateAdd("M", 1 * -1, lastQMonthDate)) & "#))
GROUP BY MonthlyQ.CategoryID, MonthlyQ.ProductID, " & txtPeriod & ", VenClassID ;"
Manually calculate a value for AMC using the numbers that the query would use and compare your value to the query calculation value.
I'll try and modify your function as I would write it to give you an idea of how I format the VBA code... (Not the only way, just my style that I find easy to read)