I have vba code set up to add information selected in a listbox to a table. I only need one field from the listbox added. It is in the 5th column.
I was having trouble with the code only adding blank records to the table. I added debugging code and now the code does nothing.
When I run it, I do get this message in the Immediate Window, "0 Null"
Here is the code:
Private Sub btnAddSelected_Click()
Dim frm As Form
Dim ctl As Control
Dim intCounter As Integer
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set frm = Forms("frm_Act_Enter")
Set ctl = frm![lstPrevRpts]
Set db = CurrentDb
Set rst = db.OpenRecordset("Act_SubTo_Date")
If ctl.ItemsSelected.Count > Null Then
For intCounter = Null To ctl.ItemsSelected.Count - 1
Debug.Print intCounter, ctl.Column(5, intCounter)
rst("ActID") = ctl.Column(5, intCounter)
Set rst = Nothing