Parameter Issues

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Campbell MH
    New Member
    • Aug 2020
    • 1

    Parameter Issues

    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:

    Code:
     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.
  • cactusdata
    Recognized Expert New Member
    • Aug 2007
    • 223

    #2
    Try to be more specific - assuming Param is the value of the parameter:

    Code:
    qdf20!Param1.Value = Param

    Comment

    • twinnyfo
      Recognized Expert Moderator Specialist
      • Nov 2011
      • 3663

      #3
      Campbell,

      In order for us to address any of those issues, we would need to see the QueryDefs you are using for each specific error. That is the only way we can solve those specific errors.

      Otherwise, we are simply guessing.

      Thanks!

      Comment

      Working...