Solved

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

Posted on 2007-11-30
3
388 Views
Last Modified: 2008-02-07
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
0
Comment
Question by:isischen
  • 2
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
 
LVL 39

Expert Comment

by:stevbe
Comment Utility
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
 
LVL 39

Accepted Solution

by:
stevbe earned 250 total points
Comment Utility
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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now