Results 1 to 4 of 4
  1. #1
    haleyja is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2016
    Location
    Toronto Canada
    Posts
    1

    upgrading from access 2003 to access 2010 keep getting update error or add new error

    msgbox reads.... run-time error '3346':
    number of query values and destination fields are not the same.

    below is except from the code after error message when I click debug ends up highlighting last line below.... running access 2010 ported the database from 2003.

    any help would be a headach relief.

    thanks
    James

    txtProduct.SetFocus
    strProduct = txtProduct.Text
    cboRecoverable.SetFocus
    strRecoverable = cboRecoverable.Text
    txtComments.SetFocus
    strComments = txtComments.Text
    cboCity.SetFocus
    strCity = cboCity.Text


    txtSignetRef.SetFocus
    strSignetReference = txtSignetRef.Text
    txtADD.SetFocus
    strADD = txtADD.Text
    txtModifiedBy.SetFocus
    strModifiedBy = Environ("USERNAME")
    'Declare string to hold the SQL Insert statement (makes testing easier)
    'and another to hold the current date as one of the Values in the SQL
    'Insert statement.
    Dim strSQL As String
    Dim strsqla As String
    strsqla = strSQL
    'If this is an update then the SQL UPDATE statement is executed, else the SQL
    'INSERT is executed.
    If intSwitch = 1 Then
    MsgBox "strsql first"
    strSQL = "Update [CAC Software Renewals] " & _
    "SET Product='" & strProduct & "', [Recoverable?]='" & strRecoverable & "', " & _
    "Vendor='" & strVendor & "', Software_Client='" & strSoftwareClient & "', " & _
    "Description='" & strDescription & "', CAC_Resp='" & strCACResp & "', " & _
    "ITS_Resp='" & strITSResp & "', Budget_Cost='" & strBudgetCost & "', " & _
    "IN_ITS_LOA='" & strInItsLoa & "', Paid='" & strPaid & "', " & _
    "Actual_Cost='" & strActualCost & "', Date_Paid='" & strDatePaid & "', " & _
    "Contract_End_Date='" & strContractEndDate & "', Comments='" & strComments & "', " & _
    "City='" & strCity & "', Signet_Reference='" & strSignetReference & "', " & _
    "Vendor_Contact='" & strVendorContact & "', ADD='" & strADD & "', Modified_By='" & strModifiedBy & "' " & _
    "WHERE ID=" & intID
    Else
    'Set the strSQL string equal to the Insert statement to be executed.

    strSQL = "INSERT INTO [CAC Software Renewals] " & _
    "VALUES(" & intID & ", '" & strProduct & "', '" & strRecoverable & "', " & _
    "'" & strVendor & "', '" & strSoftwareClient & "', " & _
    "'" & strDescription & "', '" & strCACResp & "' , '" & strITSResp & "', " & _
    "'" & strBudgetCost & "', '" & strInItsLoa & "', '" & strPaid & "', '" & strActualCost & "', " & _
    "'" & strDatePaid & "', '" & strContractEndDate & "', '" & strComments & "', " & _
    "'" & strCity & "', '" & strSignetReference & "', '" & strVendorContact & "', '" & strADD & "', '" & strModifiedBy & "');"
    MsgBox "else of strsql"
    End If
    'Debug.Print strSQL
    'Turn off the annoying Access warnings when adding, appending, etc. and then execute
    'the strSQL string.
    DoCmd.SetWarnings False
    MsgBox strSQL
    DoCmd.RunSQL strSQL

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Code:
    ADD='" & strADD & "', Modified_By='" & strModifiedBy & "' " & _
    Might be as simple as changing a field name. 'ADD' is a reserved word.

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Your SQL has INSERT INTO [CAC Software Renewals] VALUES.... You didn't give a list of field names that correspond to the list of values. That's fine, but when you do that, the number of values in the list must be the same as the number of fields in the destination table. There are 20 values in the list - how many fields are in [CAC Software Renewals] ? The error message suggests it is not 20.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    "Description" is also a reserved word. ("Description='" & strDescription &)
    "Description" of what??? Maybe use "SoftwareDesc" or "ProdDesc" or "ProductDesc" or ....



    Also should NOT use punctuation or special characters in object names ([Recoverable?])
    A better name might be "IsRecoverable".

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

Similar Threads

  1. #error after 2003 to 2010 Access upgrade
    By kheneasar in forum Queries
    Replies: 7
    Last Post: 04-26-2014, 09:45 AM
  2. Replies: 22
    Last Post: 02-24-2014, 10:21 PM
  3. Replies: 2
    Last Post: 02-11-2014, 09:41 AM
  4. Replies: 15
    Last Post: 07-17-2013, 11:29 AM
  5. Type mismatch Error after upgrading to Access 2010
    By twm07073 in forum Programming
    Replies: 7
    Last Post: 06-13-2012, 10:07 AM

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