Unless I've missed the point completely, I think you have almost answered your own question. The way that most people generate simple SQL strings (if they're honest) is in Query design, view the SQL, highlight the SQL string, then edit: copy it and then paste the string into your VBA sub (or function) . In front of the string type in DoCmd.RunSQL (space) [or Application.Execute] and then make sure your SQL string is in quotes(") with a final semicolon (;) before the last quote. This will give you exactly the right syntax, but the difficulties will come (if you have not done this very often)when you try to replace some of the SQL String with variables. Everything within the string must be joined with & and everything (including numbers) must also be converted to strings.
|