ndunwoodie said:
Rick,
Thanks for the replies. The syntax errors are fixed but now I get an
error stating "too few parameters. 1 expected".
First I'll clarify my previous post about delimiting the form reference.
When you run a query in the Access GUI the query can use what is called the
"Expression Service" to automatically resolve form references like
Forms!frmMissBus!cboName. If the Jet database engine (the one that Access
uses by default) is processing a query directly it does not have the benefit
of the expression service and so form references have to be explicitly
defines as parameters in the query.
There are two primary methods to execute an action query in VBA code...
DoCmd.RunSQL "SQL Statement or Query Name"
or
CurrentDB.Execute "SQL Statement or Query Name"
I prefer the second method because you can handle errors better and because
it doesn't produce the "Are you sure" prompts (which RunSQL does). However;
RunSQL does use the expression service so in some cases I will still use it.
That being said, if you delimit the form reference so that the SQL string
has the value pulled from the form reference instead of the reference itself
it solves the problem so that is what I usually do.
You can also get "missing parameters" if you spelled a field name wrong so
that is what I would double-check first.