'Data Mismatch error while using the Update query

I am using the Update query inside VBA to Update one particular column.

But I am getting the Data Mismatch in criteria expression error. Please find below the code.

Public Function UpdateDistinctColumnFRNumberBasis()

MergedInvoiceFile = "\test.xlsx"

StrInvoiceNumber = "010541-01"

FRSparepartNumber = "FT99999000006"

Application.ScreenUpdating = False

Application.Calculation = xlCalculateManual

Application.EnableEvents = False


Dim objConn As Object

Dim objRecordSet As Object

Set objConn = CreateObject("ADODB.Connection")

Set objRecCmd = CreateObject("ADODB.Command")

Set objRecCmd_Update = CreateObject("ADODB.Command")

objConn.Open ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & MergedInvoiceFile & ";Extended Properties=""Excel 8.0;""")

strSQL = "Update [Tabelle1$] SET [Distinct] = 'Distinct' Where ([RECHNR] ='" & StrInvoiceNumber & "' AND [TEILENUMMER] = '" & FRSparepartNumber & "')"
    
objConn.Execute strSQL


objConn.Close

Set objConn = Nothing

Set objRecCmd = Nothing

Set objRecCmd_Update = Nothing

End Function


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source