I am trying to assign code to a button in MS Access that will update a table record. When the button is clicked, I'd like it to reference a user-updated item number in a nearby list box (List26), lookup that matching item number field in a table (Assets), and change a field (Owner) on that record to be blank.
I have been digging around and found some logic around the DAO Recordset but I am not familiar with VBA enough to get it setup correctly or know if this is the right path. Below is what I've gotten to so far:
Private Sub Check_In_Device_Click()
Dim rec As DAO.Recordset
'Table1 called "Assets"
Set rec = CurrentDb.OpenRecordset("SELECT * FROM Assets")
'if the data in List26 matches an Item# in Asset table...
If [Item].value = [List26].value Then
rec.MoveFirst
rec.Edit
'change Owner field to null
rec![Owner].value = ""
rec.Update
rec.Close
End If
End Sub