Access Access VBA For Each Next for a Recordset

Joined
Aug 13, 2015
Messages
1
Reaction score
0
Hello,

I am fairly new to VBA programming and am trying to write code that will allow be to click a command button on a form and change a value for all records in the set to a value of Yes or 0

I have read some coding books but can't seem to get the result I want and the examples are not very "real world"

Any help would be greatly appreciated.


Kate
 
Joined
Feb 18, 2015
Messages
6
Reaction score
0
Hopefully this is a start.

Create a button on the form and in the On-Click events put the following code:

Dim rst As Recordset
Set rst = Me.Recordset 'set the form recordset to the temporary record set

Do While Not rst.EOF
rst.Edit
'field_name is the name of the field you want to update
rst![field_name] = "UPDATED VERSION2"
rst.Update
rst.MoveNext
Loop
Me.Form.Refresh

This will update all the records on the form and then refresh the form to show the updates.
 

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