samonwalkabout
Registered User.
- Local time
- Today, 05:25
- Joined
- Mar 14, 2003
- Messages
- 185
Im attempting to edit a few fields of a selected records in a combo box. I often use a piece of code given to me by Pat in a earlyer thread. I have changed the code somewhat but can seem to get it too loop through the selected records and edit the fields i want. Heres the code. It runs but will only update the frist item in the tbl??
Public Function addraw(ctlRef As ListBox) As String
On Error GoTo Err_adder
Dim i As Variant
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qd As DAO.QueryDef
Set dbs = CurrentDb
Set qd = dbs.QueryDefs!qryrawmat
Set rst = qd.OpenRecordset
For Each i In ctlRef.ItemsSelected
rst.edit
rst!RawMaterialID = Me.RawList 'listbox of rawmaterial id's
rst.Update
Next i
Set rst = Nothing
Set qd = Nothing
Public Function addraw(ctlRef As ListBox) As String
On Error GoTo Err_adder
Dim i As Variant
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qd As DAO.QueryDef
Set dbs = CurrentDb
Set qd = dbs.QueryDefs!qryrawmat
Set rst = qd.OpenRecordset
For Each i In ctlRef.ItemsSelected
rst.edit
rst!RawMaterialID = Me.RawList 'listbox of rawmaterial id's
rst.Update
Next i
Set rst = Nothing
Set qd = Nothing