Hey,
I am pretty new to programming in Access and I am trying to update fields in a table in a simple manner. This is my code:
Function FillProdCode()
1
2 Dim rstFoundItems As Recordset
3 Dim rs As DAO.Recordset
4 Dim cursku As String
5
6 Set rs = CurrentDb.OpenRecordset("FoundItems")
7
8 If Not (rs.EOF And rs.BOF) Then
9 rs.MoveFirst
10 Do Until rs.EOF = True
11
12 If rs!Level = 0 Then
13
14 cursku = rs!Item_Number
15
16 End If
17
18 With rs
19 .Edit
20 .Fields("Prod_Code").Value = cursku
21 .Update
22 End With
23
24 rs.MoveNext
25 Loop
26 Else
27 MsgBox "There are no records in the recordset."
28 End If
29
30 MsgBox "Finished looping through records."
31
32 rs.Close
33 Set rs = Nothing
34
End Function
I get "Run-time error '3265': Item not found in this collection." on the line 20.
Does anyone know what I'm doing wrong?