0

I'm trying to use the Execute command in Access VBA code to run a saved update query (that changes some information in a select query) but I keep getting: "Runtime Error 3061 - Too few parameters, expected 3".

The update query has no criteria but the select query that it is editing does have a few criteria that are based on some TempVars. Here is the first criteria the select query uses:

Like IIf([TempVars]![VarAccessLevel] Between 3 And 4,"*",[TempVars]![VarLoginID])

The second criteria used is: [TempVars]![VarClassBlockChosen]

I'm assuming the TempVars are the 3 parameters it is looking for, but I have no clue how to go about providing them.

Here is the VBA code I have written.

CurrentDb.Execute "qupdMarkAllAsPresent", dbFailOnError

Notably, I started out with Do.Cmd OpenQuery "qupdMarkAllAsPresent" and it worked fine but after I attempted to switch to the Execute command (to prevent warning messages) it began asking for parameters.

Tre S
  • 101
  • 2
  • 2
    [This answer](https://stackoverflow.com/a/49509616/7296893) provides an overview of all ways to pass parameters to queries. You should look at the _Using DAO_ section for the syntax, and will have to swap `CurrentDb.Execute` for using a QueryDef. – Erik A Jan 08 '19 at 08:48
  • Are these coming from a Form? If so it is [Forms]![TempVars]![VarAccessLevel] or sometimes you can just use Me![TempVars]![VarAccessLevel] – smoore4 Jan 08 '19 at 09:07
  • Set the TempVars – kismert Jan 15 '19 at 02:44

0 Answers0