Search and Replace

northy

Registered User.
Local time
Today, 19:35
Joined
Jul 30, 2001
Messages
16
What is the best way to search a table for a record and change one of the values in its fields?

[This message has been edited by northy (edited 09-05-2001).]
 
Perhaps I am missing something, but I think you just use the following:

Code:
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblYourTableName", dbOpenDynaset)
With rs
     .FindFirst "Your Criteria"
     .Edit
     !FieldName = "UpdatedInfo"
     .Update
End With
 
Sorry I have not be clear about this...

I don't want to change the name of the field, I want to search a specific field (eg Field1) for my condition and then change the actual entry in a different field of the same record (eg Field2). How can I do this?

Thanks
 
My best advice for you is to use the Search on this forum....
Its amazing what you will find, and what you are asking has been answered many times, so I am sure you will find what you want.

HTH
 
While I agree with Braindead (that doesn't sound right!
smile.gif
), the code I gave you above does exactly what you want to do. It does not change the name of the field. It changes the entry in that field for the record that was found with your criteria.
 
Fair enough...

I'm sure you'll be pleased to know that this foray into the world of Access and VBA is only temporary and I would imagine that this is the last stupid question (from me at least) you'll have to answer.

Thanks for all the help
 
Don't give up, there are a great many here who don't regard newbies to Access or vba as stupid. Access and vba can become fascinating and addictive once you overcome initial frustration, and even the "experts" suffer the same frustrations from time to time.
 
northy,

I hope you didn't take my response to imply that I didn't think your question was appropriate. Please, post away!

I guess I am just noticing more and more that the same questions appear often in these forums (or are easily answered in Access Help files), showing that the poster didn't put any effort in to finding the answer themselves first.

I'm sorry if I came off wrong.

[This message has been edited by shacket (edited 09-06-2001).]
 
shacket's method definitely will work.

You can also build a Select Query that filters the records to only return those based on the criteria you set. After you a sure the query returns the need records, simply change this Select Query to an Update Query. If this is only needed for a "one time deal", delete this query once you have completed the task at hand.

HTH
RDH
 
Don't worry guys...

This site is a great resource and sometimes it is just a bit too tempting to ask a question without having fully researched its answer first. I'm only dabbling in this stuff for a quick project so don't be alarmed when I disappear never to be seen again...it's certainly not the attitude of the posters that will have caused this.

By the way...my project now works fine.

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom