intern2012
New member
- Local time
- Yesterday, 19:32
- Joined
- Jul 11, 2012
- Messages
- 3
Hi,
I'm trying to write a VBA function (for a Command Button on a Form) that edits a table. I need the function to set one field to a common value for all records. The value is entered into a textbox on the form. I've poked around the internet looking for hints, and this is what I have:
Sub Command55_Click()
Dim r As Recordset
Set r = CurrentDb.OpenRecordset("INVOICE_NEW")
CurrentDb.OpenRecordset ("INVOICE_NEW")
r.MoveFirst
r.Edit
r.Fields("WEEK_NBR") = Me.WEEK_NBR_BOX.Value
r.Update
r.MoveNext
End Sub
But it doesn't appear to do anything at all. The MoveNext command is there because ultimately I want to have a loop that applies the same update to all records in the table. Before I even attempt that, though, I want to know that this much of it works. I have Excel VBA experience, and I've gotten a few things to work in Access before, but I'm still pretty new at this. Any help would be appreciated. Thanks.
I'm trying to write a VBA function (for a Command Button on a Form) that edits a table. I need the function to set one field to a common value for all records. The value is entered into a textbox on the form. I've poked around the internet looking for hints, and this is what I have:
Sub Command55_Click()
Dim r As Recordset
Set r = CurrentDb.OpenRecordset("INVOICE_NEW")
CurrentDb.OpenRecordset ("INVOICE_NEW")
r.MoveFirst
r.Edit
r.Fields("WEEK_NBR") = Me.WEEK_NBR_BOX.Value
r.Update
r.MoveNext
End Sub
But it doesn't appear to do anything at all. The MoveNext command is there because ultimately I want to have a loop that applies the same update to all records in the table. Before I even attempt that, though, I want to know that this much of it works. I have Excel VBA experience, and I've gotten a few things to work in Access before, but I'm still pretty new at this. Any help would be appreciated. Thanks.