syntax of ADODB.recordset's UPDATE with variable used in FIELD and VALUE argument?

I want to use ADODB.RECORDSET 's UPDATE method but I need to use variable in the FIELDS AND VALUES argument.
  'recordset.update fields,values
isischenAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
stevbeConnect With a Mentor Commented:
ack ,... typos ...

Dim strField As String
Dim varValue As Variant

'set your field and value variables ...
strField = "CustomerName"
varValue = "Microsoft"

'then pass them in like this ...
rst.Fields(strField).Value = varValue
rst.Update

Steve
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
recordset.update will use the fields collection actual vs retrieved values, so, it will rather work like this:

recordset.fields("field").value = "value"
...
recordset.update

and adodb will generate and run the sql for you.

if fields and values are 2 collections/array/... you "just" need to loop through them and make the line to assign the value "dynamic"...
0
 
stevbeCommented:
Dim strFile As String
Dim varValue As Variant

'set your field and value variables ...

'then pass them in like this ...
rst.Fields(strField).Value = varValue
rst.Update

Steve
0
All Courses

From novice to tech pro — start learning today.