Solved

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

Posted on 2007-11-30
3
399 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]
ID: 20387395
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
ID: 20388231
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
ID: 20388236
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

910 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

20 Experts available now in Live!

Get 1:1 Help Now