[AccessD] ADO OpenRecordest with Update

jeffrey.demulling at usbank.com jeffrey.demulling at usbank.com
Wed Oct 15 12:17:28 CDT 2003




What you need to do with the ADO is something similar to the following:

Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cmdtext As String

con = setconnection
con.Open

cmdtext = "UPDATE tblRatingAgencies"
cmdtext = cmdtext & " SET"
cmdtext = cmdtext & " tblRatingAgencies.[AgencyName] = '" &
Me.txtAgencyName & "'"
cmdtext = cmdtext & " WHERE (((tblRatingAgencies.AgencyNumber)=" &
Forms![frmRatingAgencies]![frmRatingAgencies-SubForm]![txtAgencyNumber] &
"));"

MsgBox cmdtext

rs.Open cmdtext, con

con.Close

Also you might want to take a look at the actual SQL string you are
passing.  Just uncomment out the indicated line and a message box will
dispaly your actual SQL.

HTH

-Jeff

>
> Is it possible to have an ADO openrecordset ("sql_string") where the
> sql_string is an UPDATE statement? I see examples with SELECTs but no
> Update.
>
> We are getting error 3219 Invalid Operation
>
>  mySql = "UPDATE MyTable SET item_ref_date = Now()
>   WHERE item_id = 16;"
>
> Thanks
>
> jack
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com









More information about the AccessD mailing list