Results 1 to 6 of 6
  1. #1
    Thompyt is offline Expert
    Windows 11 Office 365
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862

    Runtime Error '3061': Too few parameters, Expected 32

    When I use this Update query in Access it updates the fields in the table:

    Code:
    UPDATE QryCostDiff LEFT JOIN TblActCosts ON QryCostDiff.CON_ID = TblActCosts.ActCON_ID SET TblActCosts.ActGNDTVL = [Forms]![FrmCostDifferences].[ActGNDTVL], TblActCosts.ActTDYStart = [Forms]![FrmCostDifferences].[ActTDYStart], TblActCosts.ActTDYStop = [Forms]![FrmCostDifferences].[ActTDYStop], TblActCosts.ActPDLodge = [Forms]![FrmCostDifferences].[ActPDLodge], TblActCosts.ActLodgeTTL = [Forms]![FrmCostDifferences].[ActLodgeTTL], TblActCosts.ActLodgeTax = [Forms]![FrmCostDifferences].[ActLodgeTax], TblActCosts.ActLodgeWTaxTTL = [Forms]![FrmCostDifferences].[ActLodgeWTaxTTL], TblActCosts.ActPDMeal = [Forms]![FrmCostDifferences]![ActPDMeal], TblActCosts.ActMealTTL = [Forms]![FrmCostDifferences].[ActMealTTL], TblActCosts.ActRent_Type = [Forms]![FrmCostDifferences].[ActRent_Type], TblActCosts.ActRCost = [Forms]![FrmCostDifferences].[ActRCost], TblActCosts.ActFuel = [Forms]![FrmCostDifferences].[ActFuel], TblActCosts.ActRentTTL = [Forms]![FrmCostDifferences]![ActRentTTL], TblActCosts.ActRentTaxTTL = [Forms]![FrmCostDifferences].[ActRentTaxTTL], TblActCosts.ActRentTtlWTax = [Forms]![FrmCostDifferences].[ActRentTtlWTax], TblActCosts.ActBkFee = [Forms]![FrmCostDifferences].[ActBkFee], TblActCosts.ActH2AIRTTL = [Forms]![FrmCostDifferences].[ActH2AIRTTL], TblActCosts.ActAirPark = [Forms]![FrmCostDifferences].[ActAirPark], TblActCosts.ActCarrier = [Forms]![FrmCostDifferences].[ActCarrier], TblActCosts.ActAirfare = [Forms]![FrmCostDifferences].[ActAirfare], TblActCosts.ActBagNum = [Forms]![FrmCostDifferences].[ActBagNum], TblActCosts.ActBagCost = [Forms]![FrmCostDifferences].[ActBagCost], TblActCosts.ActExcessBagCost = [Forms]![FrmCostDifferences].[ActExcessBagCost], TblActCosts.ActBag = [Forms]![FrmCostDifferences].[ActBag], TblActCosts.ActTolls = [Forms]![FrmCostDifferences].[ActTolls], TblActCosts.ActTvlTTL = [Forms]![FrmCostDifferences].[ActTvlTTL], TblActCosts.ActOtherTTL = [Forms]![FrmCostDifferences].[ActOtherTTL], TblActCosts.ActLegTTL = [Forms]![FrmCostDifferences].[ActLegTTL], TblActCosts.ActTTLEWWHrs = [Forms]![FrmCostDifferences].[ActTTLEWWHrs], TblActCosts.ActODCCost = [Forms]![FrmCostDifferences].[ActODCCost], TblActCosts.ActTitels = [Forms]![FrmCostDifferences].[ActTitels]
    WHERE (((TblActCosts.ActCON_ID)=[Forms]![FrmCostDifferences].[ActCON_ID]));
    Yet when I put this in VBA so that I don't have to select and open a query and it stays hidden

    Code:
        CurrentDb.Execute "UPDATE QryCostDiff LEFT JOIN TblActCosts ON QryCostDiff.CON_ID = TblActCosts.ActCON_ID SET " & _   
         "TblActCosts.ActGNDTVL = [Forms]![FrmCostDifferences].[ActGNDTVL], TblActCosts.ActTDYStart = [Forms]![FrmCostDifferences].[ActTDYStart], " & _
        "TblActCosts.ActTDYStop = [Forms]![FrmCostDifferences].[ActTDYStop], TblActCosts.ActPDLodge = [Forms]![FrmCostDifferences].[ActPDLodge], " & _
        "TblActCosts.ActLodgeTTL = [Forms]![FrmCostDifferences].[ActLodgeTTL], TblActCosts.ActLodgeTax = [Forms]![FrmCostDifferences].[ActLodgeTax], " & _
        "TblActCosts.ActLodgeWTaxTTL = [Forms]![FrmCostDifferences].[ActLodgeWTaxTTL], TblActCosts.ActPDMeal = [Forms]![FrmCostDifferences]![ActPDMeal], " & _
        "TblActCosts.ActMealTTL = [Forms]![FrmCostDifferences].[ActMealTTL], TblActCosts.ActRent_Type = [Forms]![FrmCostDifferences].[ActRent_Type], " & _
        "TblActCosts.ActRCost = [Forms]![FrmCostDifferences].[ActRCost], TblActCosts.ActFuel = [Forms]![FrmCostDifferences].[ActFuel], " & _
        "TblActCosts.ActRentTTL = [Forms]![FrmCostDifferences]![ActRentTTL], TblActCosts.ActRentTaxTTL = [Forms]![FrmCostDifferences].[ActRentTaxTTL], " & _
        "TblActCosts.ActRentTtlWTax = [Forms]![FrmCostDifferences].[ActRentTtlWTax], TblActCosts.ActBkFee = [Forms]![FrmCostDifferences].[ActBkFee], " & _
        "TblActCosts.ActH2AIRTTL = [Forms]![FrmCostDifferences].[ActH2AIRTTL], TblActCosts.ActAirPark = [Forms]![FrmCostDifferences].[ActAirPark], " & _
        "TblActCosts.ActCarrier = [Forms]![FrmCostDifferences].[ActCarrier], TblActCosts.ActAirfare = [Forms]![FrmCostDifferences].[ActAirfare], " & _
        "TblActCosts.ActBagNum = [Forms]![FrmCostDifferences].[ActBagNum], TblActCosts.ActBagCost = [Forms]![FrmCostDifferences].[ActBagCost], " & _
        "TblActCosts.ActExcessBagCost = [Forms]![FrmCostDifferences].[ActExcessBagCost], TblActCosts.ActBag = [Forms]![FrmCostDifferences].[ActBag], " & _
        "TblActCosts.ActTolls = [Forms]![FrmCostDifferences].[ActTolls], TblActCosts.ActTvlTTL = [Forms]![FrmCostDifferences].[ActTvlTTL], " & _
        "TblActCosts.ActOtherTTL = [Forms]![FrmCostDifferences].[ActOtherTTL], TblActCosts.ActLegTTL = [Forms]![FrmCostDifferences].[ActLegTTL], " & _
        "TblActCosts.ActTTLEWWHrs = [Forms]![FrmCostDifferences].[ActTTLEWWHrs], TblActCosts.ActODCCost = [Forms]![FrmCostDifferences].[ActODCCost], " & _
        "TblActCosts.ActTitels = [Forms]![FrmCostDifferences].[ActTitels] " & _
        "WHERE (((TblActCosts.ActCON_ID)=[Forms]![FrmCostDifferences].[ActCON_ID]));"
    I get "Runtime Error '3061': Too few parameters, Expected 32"



    ActCON_ID is numerical

    I changed "WHERE (((TblActCosts.ActCON_ID)=[Forms]![FrmCostDifferences].[ActCON_ID]));" to "WHERE TblActCosts.ActCON_ID= """ & [Forms]![FrmCostDifferences].[ActCON_ID] & ";"""
    then I get "Runtime Error '3061': Too few parameters, Expected 31"

    Am I getting the concatenation incorrect?

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Put the concatenation into a string variable and debug.print it in the code before the execute.

    strSQL = " blah blah blah"
    Debug.Print strSQL

    The resulting string should make it obvious where the problem is.
    If you can't see it paste it into the query designer SQL window and switch to design view and then it should be more obvious.

    If you still can't see the problem post the result here and someone might be able to spot it.

    EDIT - Just noticed you aren't concatenating the form variables. VBA doesn't understand the Form! references.

    You'll need to do something like

    Code:
        "TblActCosts.ActGNDTVL = " & [Forms]![FrmCostDifferences].[ActGNDTVL] & ",  TblActCosts.ActTDYStart = " & [Forms]![FrmCostDifferences].[ActTDYStart] & ", " & _
    The above assumes numeric values, text values will need delimiting with single quotes or treble double quotes, Dates formatted with hashes as a delimiter : #yyyy-mm-dd#
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Why not use a bound form?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    assign your sql to a string and debug.print it - that is standard development practice

    Code:
    dim sqlstr as string
    
    sqlstr="UPDATE QryCostDiff LEFT JOIN........" 
    debug.print sqlstr
    'now copy the string from the immediate window to a new query and try to execute it or compare with your original query
    currentdb.execute sqlstr
    

  5. #5
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    @CJ That is also my normal modus operandi however if the string comes out with all the forms references, instead of failing in the normal query window it will probably work.

    Hopefully we might hear back from the OP.
    Last edited by Minty; 11-28-2024 at 05:26 PM.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    @minty - sorry - didn't see your post until after I posted mine!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Runtime Error 3061 Too few parameters. Expected 1
    By Thompyt in forum Programming
    Replies: 2
    Last Post: 10-02-2024, 03:25 PM
  2. Replies: 9
    Last Post: 05-29-2023, 01:04 AM
  3. Replies: 3
    Last Post: 04-03-2021, 03:10 PM
  4. Replies: 4
    Last Post: 11-19-2018, 03:26 PM
  5. Runtime Error 3061. Too few parameters, expected 2
    By Gina Maylone in forum Programming
    Replies: 35
    Last Post: 01-13-2014, 02:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums