Cannot Update Date Fields in Excel Named Range with SQL Using ADODB from VBA -
i trying run vba-sql update existing entries in excel table. data move db, not until after rollout , testing internal application small group. have been able update text (string) fields connection, date fields not allow me update. date fields problem. microsoft.ace api recognizing them date format.
the code follows, both methods , respective errors in code,
dim cn adodb.connection dim rs adodb.recordset dbfullname = thisworkbook.path & "\" & thisworkbook.name cnct = "provider=microsoft.ace.oledb.12.0;data source='" & dbfullname & "';" & _ "extended properties='excel 12.0 macro;readonly=0;hdr=yes'" set cn = new adodb.connection cn.open connectionstring:=cnct ‘ method #1 strsql = “update statusdata set [last update]=#2014-10-02 12:00:00# [program category]='cat' , [program name]='prog' , [ln] null , [sn]='sn';” cn.execute strsql, recordsaffected, adexecutenorecords error “cannot update ‘(expression)’; field not updateable.”
‘ method #2 strsql = “select * statusdata [program category]='cat' , [program name]='prog' , [ln] null , [sn]='sn';” set rs = new recordset rs.open strsql, cn, adopendynamic, adlockoptimistic rs.movefirst rs.fields("last update").value = '"#10/2/2014 04:00:00 pm#" error “field cannot updated.”
rs.update rs.close cn.close set rs = nothing set cn = nothing
method #1 worked once cell formula removed field. formulas read-only documented microsoft , other posts.
Comments
Post a Comment