How find a record in VBA recordset ?

R

Ryan

In an open recordset, I need to position on a record to update it. How do I do it
I need to find based on a criteria like 'columnname = value
I am using DAO not AD
To add records I am using .Addnew followed by .Updat

I looked in Access help but could not find anything
 
T

Tim Ferguson

I need to find based on a criteria like 'columnname = value'

rsMyRecordset.FindFirst "ColumnName = ""Value"""
If rsMyRecordSet.NoMatch Then
MsgBox """Value"" was not found"

Else
rsMyRecordset.Edit
rsMyRecordset!ColumnName = "NewValue"
rsMyRecordset.Update

End If


or what about the faster, more maintainable, portable and friendlier to
your network admin and other users:-

UPDATE MyTable SET ColumnName = "NewValue"
WHERE ColumnName = "Value";


Hope that helps


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top