I'm attempting to execute some SQL by connecting to a MSAccess database. The SQL works perfectly as a query, but it encounters an error when trying to execute from within the Excel VBA. I utilize this same method do execute a lot of SQL through the database, and haven't encountered this error before.
Sub ReassignPostScript()
' Variable Declaration Start
Dim MyConn, objRecordSet
Dim sSql
Dim myfd 'folder path for files (use network paths when available!)
myfd = "Path\To\Database"
Dim mydb 'For referencing a database
mydb = "DatabaseName.accdb"
' Variable Declaration End
' Setting Environment and database connection start
Set MyConn = CreateObject("ADODB.Connection")
MyConn.Provider = "Microsoft.ACE.OLEDB.12.0;"
MyConn.Open myfd & "\" & mydb
' Setting SQL statment to null
sSql = ""
' Query to update tblName eCRM Activity String
sSql = "UPDATE tblName SET tblName.InnoLog = Trim(Mid([InnoLog],InStr([InnoLog],' ')+1,(InStrRev([InnoLog],' ')+1)-(InStr([InnoLog],' ')+1))) " & _
"WHERE (((tblName.InnoStatus) Like '%S:CRM_USERFACE:006%') and ((tblName.InnoLog) Like 'Transaction%') );"
MyConn.Execute (sSql)
End Sub
The part that I'm trying to execute is the middle part of this string, between the two spaces
Any help/advice you all could provide would be greatly appreciated.
Thanks!