sql - Trying to use VBA variable in Access UPDATE Statement -


so title says trying use vba variable within update statement. being used because want loop through each cell in range , subtract value worksheet value within table corresponding iterations cell reference. however, statement runs error saying "too many parentheses." however, odd me b/c pulled sql syntax directly out of access. guess missing something? post both versions of code:

code vba variables :

private sub updizzle()     dim rcell range     dim rrng range     dim con new adodb.connection     dim rs new adodb.recordset     dim strconnection string     dim quv long     dim iid string      set rrng = activeworkbook.sheets("sheet1").range("b2:b100")      each rcell in rrng.cells         if rcell <> "" , rcell.value <> 0            iid = rcell            quv = rcell.offset(0,x).value             strconnection = "provider=microsoft.ace.oledb.12.0;data source=c:\users\ashleysaurus\desktop" & "\" & "xyzmanu3.accdb"             con.open strconnection             rs.open "update stuff set stuff.quantity = quantity-" & quv & " (((stuff.[itemid])=" & iid & "));", con             con.close         end if     next rcell  end sub 

code without variable:

    strconnection = "provider=microsoft.ace.oledb.12.0;data source=c:\users\ashleysaurus\desktop" & "\" & "xyzmanu3.accdb"     con.open strconnection     rs.open "update stuff set stuff.quantity = quantity-1 (((stuff.[itemid])=thingamagig));", con     con.close 

as iid string shouldn't

    rs.open "update stuff set stuff.quantity = quantity-" & quv & " (((stuff.[itemid])='" & iid & "'));", con   

(single quotes around iid)


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -