I use the below code in part with running multiple update queries with parameters in code. Hope this helps. gdb = currentdb.
Code:
Public Function ExecuteParamterQuery(ByVal strQueryName As String, _
ParamArray pArray() As Variant) As Recordset
' Written by alex miglin/perceptus 5/28/2012
Dim Myqdf As DAO.QueryDef ' Query Definition
Dim intCounter As Integer ' Used For loop
On Error GoTo Err_ExecuteParamterQuery
Set Myqdf = gdb.QueryDefs(strQueryName)
If UBound(pArray) > LBound(pArray) Then
For intCounter = LBound(pArray) To UBound(pArray) Step 2
Myqdf.Parameters(pArray(intCounter)) = pArray(intCounter + 1)
Next intCounter
End If
Set ExecuteParamterQuery = Myqdf.Execute
Safe_ExecuteParamterQuery:
Myqdf = Nothing
Exit Function
Err_ExecuteParamterQuery:
WarningBox "This query did not work." & vbCrLf & vbCrLf & Myqdf.SQL
End Function