Hint - You can build your query using the query builder, then change it to
SQL view and copy the code and paste it into your VBA editor. You will
have
to add quote marks and such to get it correct, but you would be suprised
at
how many of us do this on a regular basis. So first type in:
strSQL = "
Then paste in your SQL code you copied. Add the " at the end.
You will also have to take out any references to controls on your form out
of the quotes. For example, it may come over as
"WHERE (((tblYTDDetail.acctgunit) Like
[forms]![frmYTDLaborSelection]![acctgunit] And (tblYTDDetail.acctgunit)
Like
[forms]![frmYTDLaborSelection]![acctgunit]) AND ((tblYTDDetail.activity)
Like
[forms]![frmYTDLaborSelection]![activity]))"
You will need to change like this:
"WHERE (((tblYTDDetail.acctgunit) Like " &
[forms]![frmYTDLaborSelection]![acctgunit] & " And
(tblYTDDetail.acctgunit)
Like " & [forms]![frmYTDLaborSelection]![acctgunit]) & " AND
((tblYTDDetail.activity) Like " &
[forms]![frmYTDLaborSelection]![activity]))
'"
That is so the values of the controls are included in strSQL instead of
the
name of the form.
One last thing. Don't use DoCmd.RunSQL. It is very slow. The better way
is:
CurrentDB.Execute(strSQL)
Good Luck!
Ken Ivins said:
I am trying to run an action query called "qryDeleteBlankPayableTo" using
VBA. I see I need to do it with the DoCmd.RunSQL.
My problem is that I know very little (almost none) SQL.
So I could use help on the proper format and text to do this.
Thanks,
Ken