SOS
Registered Lunatic
- Local time
- Today, 10:53
- Joined
- Aug 27, 2008
- Messages
- 3,514
This is a little confusing to me. I've this problem for work. I have a query that has a parameter on it. The value is provided by a form (combo box for a year) and the field has a long integer datatype.
This query is actually a sub, sub query for this one that builds a table of invoices (I didn't build this code, just have to work with it), and this query gathers invoice values based on the PeriodYear and has been hand changed each year to less than the current year. So, manually someone goes in and changes it to < 2010 and next year < 2011, etc.
I am trying to use this combo box to select the year. However, the query that gets the value works fine if you run it by itself. Or if you run the next query up the line where this one is a subquery in and then the next one up the line (top level) which is fine if done manually. If I run it using code like:
Set rstInvoice = cDB.OpenRecordset("SELECT * FROM " & mstrQueryName & " WHERE MGPOrgFK Is Not Null ORDER BY Property_ID", _
dbOpenSnapshot)
Then it bombs, and says Too Few Parameters Expected 1.
So, I've tried using this:
But it bombs out giving me the error message -
Error 3421 Data Type Conversion Error
If I change it to this:
Then I still get the Too Few Parameters Expected 1 error.
So, I'm not sure how to make the change to pass the parameter to the sub, sub query and still call the main query.

This query is actually a sub, sub query for this one that builds a table of invoices (I didn't build this code, just have to work with it), and this query gathers invoice values based on the PeriodYear and has been hand changed each year to less than the current year. So, manually someone goes in and changes it to < 2010 and next year < 2011, etc.
I am trying to use this combo box to select the year. However, the query that gets the value works fine if you run it by itself. Or if you run the next query up the line where this one is a subquery in and then the next one up the line (top level) which is fine if done manually. If I run it using code like:
Set rstInvoice = cDB.OpenRecordset("SELECT * FROM " & mstrQueryName & " WHERE MGPOrgFK Is Not Null ORDER BY Property_ID", _
dbOpenSnapshot)
Then it bombs, and says Too Few Parameters Expected 1.
So, I've tried using this:
Code:
Set qdf = CurrentDb.QueryDefs("qryInvoiceDetail")
qdf.Parameters("PeriodYear") = "< " & Forms!frmQSRMain.cboInvoiceYear
Set cDB = CurrentDb
Set rstInvoiceTable = cDB.OpenRecordset(mstrTableName, dbOpenDynaset)
But it bombs out giving me the error message -
Error 3421 Data Type Conversion Error
If I change it to this:
Code:
qdf.Parameters("PeriodYear") = Forms!frmQSRMain.cboInvoiceYear
Then I still get the Too Few Parameters Expected 1 error.
So, I'm not sure how to make the change to pass the parameter to the sub, sub query and still call the main query.
