Using a pop-up form I am trying to select specific records (Child Service Users) from a list box (called Childlist) and then update a particular field (Dateended) in the table (tblServiceUse) based on the date selected in a text box(txtDateServiceEnd) on the form.
Using the following code the ServiceUseID (the key field in the tblServiceUse table) does not change so I can't get the specific records to match the ServiceUseID. How do I go through the ServiceUseIDs to find matches and thus update the required field?
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim varItem As Variant
Dim val As Integer
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblServiceuse"
For Each varItem In Me!ChildList.ItemsSelected
val = Me!ChildList.Column(0, varItem)
If rst!ServiceUseID = val Then
rst![Dateended] = Me!txtDateServiceEnd
rst.Update
End If
Next varItem
rst.Close
Set dbs = Nothing
I had played with using an Update Query for this task. I could get an update for all users of the service to function correctly but couldn't figure out how to use only the selected items in the list box to achieve the desired outcome.
If anyone can help with this I would be most grateful.
Many thanks
John R
Using the following code the ServiceUseID (the key field in the tblServiceUse table) does not change so I can't get the specific records to match the ServiceUseID. How do I go through the ServiceUseIDs to find matches and thus update the required field?
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim varItem As Variant
Dim val As Integer
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblServiceuse"
For Each varItem In Me!ChildList.ItemsSelected
val = Me!ChildList.Column(0, varItem)
If rst!ServiceUseID = val Then
rst![Dateended] = Me!txtDateServiceEnd
rst.Update
End If
Next varItem
rst.Close
Set dbs = Nothing
I had played with using an Update Query for this task. I could get an update for all users of the service to function correctly but couldn't figure out how to use only the selected items in the list box to achieve the desired outcome.
If anyone can help with this I would be most grateful.
Many thanks
John R