How to show field/row serial number on detail data report without use data environment?

simply view like this

| 1 |N0.000001|10-01-1|
| 2 |N0.000002|10-01-2|
| 3 |N0.000003|10-01-3|
| 4 |N0.000004|10-01-4|
| 5 |N0.000005|10-01-5|

You do not have to use Data Report, you can use something like the Listview Control etc. The Listview can sort data in columns etc.

i see
but I want to view the report, and it can be printed.
and I usually use Data Deport.

but yours is okay. I will be learn.

If you use the VB6 Data Report, you have to use the Data Environment, because the report needs to be connected to your database, which is only available through the data environment.

You can use third party tools as well like Crystal Reports etc. The easiest in your situation would be the Listview, which you can still view AND print as in a normal data report. Just google Listview in VB6, there is plenty of tutorials on the Listview with code samples.

Good luck.

Let Me try, so thanks v much :)

This will do the trick :)

dim rsReport as ADODB.Recordset
dim n as integer

'create temporary recordset
Set rsReport = New ADODB.Recordset
With rsReport
Set .ActiveConnection = Nothing
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Fields.Append "Serial", adBigInt 'show your serial
.Fields.Append "Column1", adVarChar, 50
.Fields.Append "Column2", adVarChar, 50

End With

'copy your recordset, assume rs is your active recordset
Do While Not rs.EOF
rsReport.Fields("Serial") = n
rsReport.Fields("Column1") = rs.Fields(0)
rsReport.Fields("Column2") = rs.Fields(1)

'generate your serial here

'finally, bound to your datareport
With DataReport1
Set .DataSource = rsReport

'bound your report on detail section here
With .Sections("Section3")
end with

end with