1. database in access
  2. ADO is in use
  3. Datareport is designed.
  4. I have 40 records in Recordset.
  5. I want create one page per record in recordset.

It just create one page report for only first record

Private Sub Command1_Click()
Dim cnString As String
    Set rs = New ADODB.Recordset
    cnString = "Select * from Main"
    rs.Open cnString, cn, adOpenStatic, adLockOptimistic

    Set DataReport1.DataSource = rs
    If Not rs.EOF Then
        DataReport1.Sections(4).ForcePageBreak = rptPageBreakAfter
        DataReport1.Show
        rs.MoveNext
    End If
End Sub

Recommended Answers

All 3 Replies

Change this part...

Set DataReport1.DataSource = rs
    If Not rs.EOF Then
        DataReport1.Sections(4).ForcePageBreak = rptPageBreakAfter
        DataReport1.Show
        rs.MoveNext
    End If

to ...

    If Not rs.EOF Then
        Set DataReport1.DataSource = rs

        DataReport1.Sections(4).ForcePageBreak = rptPageBreakAfter
        DataReport1.Show
        rs.MoveNext
    End If

I am not sure why you would want to show 40 seperate report pages though. It will consume large amounts of pc performance. Why not rather open just the record you want to view?

Each record row contain marks of a student and I like to create a marksheet for each shudent as datareport page.

I see. No problem then.

Did my above answer solve the problem though?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.