Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating A Field - in recordset

Status
Not open for further replies.

davethegog

Instructor
Oct 3, 2002
9
GB
I'm currently trying to update a field in a recordset based upon a variable defined in an earlier recordset.

eg recordset1 identifies field3 as the field to be updated so I've captured this data as a string. recordset2 will then update field3 with a specific value. I can't get the update to work. Should I prefix the fieldname with an "!"? Should I dim the field in another way. Any hints?

Dim fieldtoupdate as string
set rst1 = dbs.openrecordset("table1 queried")
with rst1
fieldtoupdate = rst1!updatefield
end with
rst1.close

set rst2 = ds.openrecordset("table2 queried")
with rst2
rst2!fieldtoupdate = "Value"
end with
rst2.close


 
Don't see any declarations of the recordsetvariables. Assumes that's done tru some dim rst2 as dao.recordset.

DAO recordsets requires the .edit and .update methods to update

Reference might be something like this:

[tt]rst2.Edit
rst2(fieldtoupdate) = "Value"
rst2.Update[/tt]

- would also be helpfull if you provided errormsg, which line etc, else we're just guessing...

Roy-Vidar
 
Royvidar

Cheers

Reading back on my thread I'd missed out quite a bit of code on the thread which appears in the real code (shouldn't rush). The line I was looking for is

rst2(fieldtoupdate) = "Value"

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top