Two things that I avoid:
1) Spaces in object names.... Apparently the name of the table is "Coded Coupons", which has a space.
2) Constantly creating and deleting objects (in this case a query).
Constantly creating and deleting the query will cause dB bloat and increases the possibility of corruption.
This is why I (manually) created the query once, then just changed the SQL property of the saved query (plus it is faster).
One other thing. There is a line in the code (by your IT dept) that is
Code:
Set qd = CurrentDb.CreateQueryDef("tmpExport", buildReportQuery)
The rule is
"If you create, it destroy it.
If you open it, close it."
Since "qd" was created (by the Set command), it should be destroyed before the sub ends.
Should add a line:
Code:
' CLEANUP
DoCmd.Hourglass (False)
Me.tbStatus = vbNullString
Set qd = Nothing '<<-- add this line
MsgBox "done"
End Sub
Happy to help. It was an interesting problem...
Good luck with your project.