I have a datatable that I fill when my application loads. This table is used to generate dataviews on the fly so I can maintain a listbox of unique values in the table.
I have the following code that works well the first time it is used, then shows no records after the second time. I am scratching my head over this one and for the life of me I can't see the problem. Maybe my understanding of tables and views is not up to par, but it looks as though it should work.
Sub RecordCnt ()
Dim dt As New DataTable
dt = Me.MyDataSet1.Names
Debug.Print("Row count")
Debug.Print(dt.Rows.Count) '<- this always returns 1415 rows
Dim cf(0) As String
cf(0) = "Route"
Dim dv As New DataView
dv = dt.DefaultView.ToTable(True, cf).DefaultView
Debug.Print("Record count")
Debug.Print(dv.Count) '<- this returns 24 the first time then 0 from then on
End Sub
I'd appreciate any insight as to why this doesn't work