Gustav Brock
gustav at cactus.dk
Tue Sep 16 11:27:27 CDT 2003
Hi Tim
> I tried that and it returns an error message "Error 3061 Too few parameters
> Expected 3". The underlying query does rely on a subquery which does have 3
> parameters but the parameters are supplied by an open form and runs just
> fine until I reference it it code. Any thoughts on why and how to fix?
Yes, do something like this with the magic of Eval():
<code>
Dim dbs As Database
Dim qdy As QueryDef
Dim prm As Parameter
Dim rst As Recordset
Set dbs = CurrentDb()
Set qdy = dbs.QueryDefs(Me.RecordSource)
For Each prm In qdy.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rst = qdy.OpenRecordset
qdy.Close
Debug.Print rst.RecordCount
rst.Close
Set rst = Nothing
Set prm = Nothing
Set qdy = Nothing
Set dbs = Nothing
</code>
You may also need to, in the query, specify the value type of the
parameters:
PARAMETERS
[Forms]![frmMain]![txtValue] Short;
/gustav
> Ahh, that is right - not until Access XP (?) I believe.
> How about
> Set rst = CurDb.OpenRecordset(Me.RecordSource)
> /gustav
>> Gustav,
>> Thanks your help. Evidently, RecordsetClone is not a property of reports,
>> only forms. Any other suggestions?