I have an Access Database that is reading data from a SharePoint list,
then outputting the data into an excel spreadsheet There are many queries involved, about 40 total.


Here is the format of each query:


Set qdf20 = db.QueryDefs("<Query Name Here>")
qdf20!Param1 = Param
Set rst20 = qdf20.OpenRecordset()
qdf20.Close
rst20.Close
Set qdf20 = Nothing
Set rst20 = Nothing


This is in a 'For' loop, and the 'Param' changes with each iteration of the loop.
The problem: Some queries work, and some do not. The only thing that is changed
is the query name, the record set name and the query def name. The errors are
totally random. The parameters are in an array, and the for the queries that work,
all the parameters are successfully transferred.


Solutions I have tried are using the Parameters Collection Object, and using the SQL commands directly in VBA, but that didn't help.
The error I receive is: "Too few parameters, expected 1". I have read the other posts concerning this same error, but they do not solve the problem.


I'm at my wits-end trying to find a solution. Can anyone offer any insight?
It would be very helpful and much appreciated.