Hello all,
I keep running into the same problem which I'm assuming is probably an easy fix but I'm just not seeing it. The error I get is "Query input must contain at least one table or query". First, I built my query. I tested my query and it seems to work. What I'm doing is pulling info from two tables (Comms2 and Misc) and adding two calculated fields (Expr1 and Expr2) all of which appends to my table "Override". I've converted the query to SQL and put it into my VBA. I have done this to other queries with success, so I'm fairly certain I cleaned up the SQL code correctly. My query does call for a vba code for the calclations but I don't think that is what is causing the current error...however, my other queries didn't call for vba coding. Below is the code.
I appreciate any help anyone can give me.
Thanks,
John
Public Sub appOverride(commDate)
Dim appOver As String
appOver = "INSERT INTO Override ( DateofComm, Instrument, MiscAmount, Store, SP1, factorBasis, overrideTotal )" & _
"SELECT Misc.DateofComm, Misc.Instrument, Misc.MiscAmount, Misc.Store, Comms2.SP1, getFactor([SP1],[Misc].[Store],[Misc].[Instrument]) AS Expr1, [MiscAmount]*getFactor([SP1],[Misc].[Store],[Misc].[Instrument]) AS Expr2" & _
"FROM Comms2 INNER JOIN Misc ON Comms2.DateofComm = Misc.DateofComm" & _
"GROUP BY Misc.DateofComm, Misc.Instrument, Misc.MiscAmount, Misc.Store, Comms2.SP1, getFactor([SP1],[Misc].[Store],[Misc].[Instrument]), [MiscAmount]*getFactor([SP1],[Misc].[Store],[Misc].[Instrument])" & _
"HAVING Misc.DateofComm= #' & commDate & '# AND Comms2.SP1='Dave M' Or Comms2.SP1='Emily Beckman' Or Comms2.SP1='Anthony T.' AND getFactor([SP1],[Misc].[Store],[Misc].[Instrument]) Is Not Null;"
DoCmd.RunSQL appOver
End Sub