I made a sub that deletes records in a table via a recordset. I would like to print the key of the record that is deleted to a textbox on a form. So after each delete the key has to be added to the textbox on the form.
Below you can find the code, that doesn't print anything to the form.
I'm missing something.
Public Sub Erase()
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Dim strOutput As String
Dim i As Integer
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("Table1", dbOpenDynaset) 'dynaset voor linked tables
If rs1.EOF Then Exit Sub
Do Until rs1.EOF
If rs1!Icoon = "del" Then
Debug.Print "Debug Print :" & rs1(0).Value
strOutput = "Ent: " & rs1(0).Value & vbCrLf
On Error Resume Next
rs1.Delete
txtOutput.value = strOutput
i = DoEvents
End If
rs1.MoveNext
Loop
rs1.Close
Set rs1 = Nothing
Set db = Nothing
End Sub
CodePudding user response:
Forgot the form ... txtOutput.value = strOutput should be: [Forms]![Frm_Main]![txtOutput] = strOutput
