Atomic Shrimp
Humanoid lifeform
- Local time
- Today, 00:30
- Joined
- Jun 16, 2000
- Messages
- 1,954
I had problems getting a query to go into a recordset in VBA, because the criteria in the query referenced a value in one of my form controls - apparently, because the query is passed to Jet for execution, and because Jet doesn't know anything about forms, it generated an error 'too few parameters - expected 1'
I sorted that problem by means of the instructions in this MS article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;209203
The solution is to create a querydef object, set the querydef object as the saved query, assign the parameter, then set the recordset as the opened result of the querydef. No problem
BUT a problem does occur when the query is based on *another* query that also needs parameters based on control values on a form.
I could try to rewrite the second query, but I'm reluctant to do so, because of the way it needs to work - Query1 selects a bunch of records based on quite complex criteria, plus a parameter from the form, query2 needs to select the precisely complementary set of records - essentially, it's a 'find unmatched' query based on the original table and the first query.
So... is there any way around this - how do I pass a parameter to a query that is underlying the one I want in my recordset?
I sorted that problem by means of the instructions in this MS article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;209203
The solution is to create a querydef object, set the querydef object as the saved query, assign the parameter, then set the recordset as the opened result of the querydef. No problem
BUT a problem does occur when the query is based on *another* query that also needs parameters based on control values on a form.
I could try to rewrite the second query, but I'm reluctant to do so, because of the way it needs to work - Query1 selects a bunch of records based on quite complex criteria, plus a parameter from the form, query2 needs to select the precisely complementary set of records - essentially, it's a 'find unmatched' query based on the original table and the first query.
So... is there any way around this - how do I pass a parameter to a query that is underlying the one I want in my recordset?