Change data in a table using code.

D

Dale

Hi,
I need some help writing code to be able to change the data in a certain
numeric field within a table, where if the value = 1, change it to 2, in
every record in the table. The table is not very large. Only about 100k
records.

Thanks for your help.
Dale
 
D

Douglas J. Steele

You're best off using an Update query to do this, even if you run it through
VBA. It's almost always significantly faster to using queries than
recordsets.


Dim strSQL As String

strSQL = "UPDATE MyTable SET MyValue = 2 WHERE MyValue = 1"
CurrentDb().Execute strSQL, dbFailOnError

Replace MyTable and MyValue with the appropriate names.
 

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