Hello all,
I have a a form which I use to populate query parameters and send the result to MS Word, where a table is created from the query. The form contains 2 controls: 1) a combo box containing the month number and 2) a text box containing a year value. The form also contains a command button that opens the query into a recordset and then creates the Word table.
The query (qryCostData) contains 2 fields that reference these form parameters. The query works when:
The query does not work when I open the query using the command button on the form and the query containes references to the month and year parameters from the form. The following error is returned on the following command:
command:
error:
Any ideas on why it works using the form command button when the parameters are hard-coded but not when referencing the form fields? If I open the form and select the parameters and then open the query through the query window, it works fine.
Thanks in advance.
Ken
I have a a form which I use to populate query parameters and send the result to MS Word, where a table is created from the query. The form contains 2 controls: 1) a combo box containing the month number and 2) a text box containing a year value. The form also contains a command button that opens the query into a recordset and then creates the Word table.
The query (qryCostData) contains 2 fields that reference these form parameters. The query works when:
- I open the query directly (query window) while the form is open w/ the month and year parameters selected
- I open the query directly (query window) when the form is closed but the month and year parameters are hard-coded into the query
- I open the query using the command button on the form when the month and year paramters are hard-coded into the query
The query does not work when I open the query using the command button on the form and the query containes references to the month and year parameters from the form. The following error is returned on the following command:
command:
PHP:
rst.open "qryCostData", CurrentProject.Connection
error:
Code:
Run-time error: -2147217900 (8004e14)
Invalid SQL statement; expected DELETE, INSERT, PROCEDURE, SELECT, or UPDATE
Any ideas on why it works using the form command button when the parameters are hard-coded but not when referencing the form fields? If I open the form and select the parameters and then open the query through the query window, it works fine.
Thanks in advance.
Ken