MS Access Error: Run-time error ‘3061’: Too few parameters expected 1

Background: While updating a record set the MS Access Error: Run-time error ‘3061’ showed up.

Workaround:

Upon investigation found the column in WHERE clause supplying wrong type of value. In the below code the [suppid] is of String type but the value supplied ” & suppidVar & “” is not a String.

 sql007 = "SELECT nz(outs,0) AS OutsAmt, outs, uptime FROM SUPPLIERS" & _
 " WHERE [suppid] = " & suppidVar & "" 
Set rs007 = CurrentDb.OpenRecordset(sql007, dbOpenDynaset, dbSeeChanges)
rs007.Edit

Resolution of MS Access Error: Run-time error ‘3061’:

Editing the supplied variable ” & suppidVar & “” as parameter to “”” & suppidVar & “””” solve the error as it finally transfers the value of suppidVar to a String.

 sql007 = "SELECT nz(outs,0) AS OutsAmt, outs, uptime FROM SUPPLIERS " & _
           "WHERE [suppid] = """ & suppidVar & """"
 Set rs007 = CurrentDb.OpenRecordset(sql007, dbOpenDynaset, dbSeeChanges)
 rs007.Edit

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.