Yes, using parameters is another way to do it. To be pedantic, parameters are not form objects and VBA is being used to pass the value from the form to the parameter. Using Execute, the query is not referencing a form object but a parameter.I don't have any trouble at all using the .execute method to run queries that reference form objects. The method requires that you set the arguments prior to the execute. Here's an example:
Code:Set qd = db.QueryDefs!q835_CopyBeforeDelete_Rebill qd.Parameters!EnterBatchID = Me.txtBatchID qd.Execute (dbFailOnError + dbSeeChanges) Debug.Print "Copy 835 before delete = " & db.RecordsAffected
The point I was making is that Minty's suggestion that it is a simple change, implying it just requires substituting RunSQL with Execute is not necessarily correct.