Dataview Copy

  • Thread starter Thread starter Dianna K.
  • Start date Start date
D

Dianna K.

I have a dataview which I am assigning to a Datatable (I
am doing this because currently Crystal Reports will not
accept a dataview as a Reportsource -- The recommended
work-around is to assign dataview to datatable).

The dataview is being filtered. However when I assign it
to the datatable it is not filtered. I put some debug
code in and the Dataview has 8 records then I assign it to
a new datatable. When I check the row count of the
Datatable it has 34 rows...??
Shouldn't the dataview only copy the 8 filtered rows???



Dim dtCrystal As DataTable

dtCrystal = dvGrid.Table.Copy


oRpt.SetDataSource(dtCrystal)
crvReport.ReportSource = oRpt
crvReport.PrintReport()

Any help would be great
Dianna
 
No, you are copying the underlying DataTable. As such, there's no filter.

I think you can foreach the rows in teh dataview and add them to the other
datatable.

Hth,

Bill
 
Hi Bill,

I tried however no such luck :( I am still getting the
entire un-filtered dataset.

MsgBox("Filter Count" & dvGrid.Count)

rptDS = OutDS.Clone 'copy structure Only

For Each objRow In dvGrid.Table.Rows
NewRow = rptDS.Tables(0).NewRow
rptDS.Tables(0).Rows.Add(NewRow)
Next

MsgBox("NEW TABLE " & rptDS.Tables(0).Rows.Count)
 
Back
Top