Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-11-30
3
Medium Priority
?
443 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 143

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 1000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

876 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