Results 1 to 11 of 11

Thread: How to dynamically set page length in data report?

  1. #1

    Thread Starter
    Addicted Member senthilkumartd's Avatar
    Join Date
    Feb 2005
    Posts
    206

    Talking How to dynamically set page length in data report?

    Hi,
    I need to set the page length dynamically in the data report. Any way to do it?

    Need:
    I wish to generate a invoice bill with food items. Based on the items the bill length varies. Thats why i need.

    Or

    Any other ways to accomplish the above thing.

    Advance thanks,
    Senthil

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to dynamically set page length in data report?

    Moved to reporting section.

  3. #3
    Junior Member
    Join Date
    Nov 2013
    Location
    Ireland
    Posts
    25

    Re: How to dynamically set page length in data report?

    Hi,

    I'm having the same problem myself and im just wondering did you ever come up with a solution?

    thanks

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,513

    Re: How to dynamically set page length in data report?

    There is no Page Length property for a DataReport. I don't understand. No matter how many items you print the paper size your printing on stays the same. If you describe your problem better maybe someone can help.

  5. #5
    Junior Member
    Join Date
    Nov 2013
    Location
    Ireland
    Posts
    25

    Re: How to dynamically set page length in data report?

    The problem that I am having is that I am creating a receipt using a reportviewer in vb pro 2012. I have it working great until there are loads of items on the receipt which need printed because then a scroll bar appears and unless the user scrolls down to view the other items they are not displayed. I have tried using auto scroll = false, auto size = true and also tried using the scrollable print option on the print form component. The reportviewer is being displayed on a form and what I need is for the form and reportviewer to get longer based on how many items there are in the report so that the full thing can be printed. Any help or advice would be greatly appreciated.

  6. #6
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,513

    Re: How to dynamically set page length in data report?

    First, I think you would have better luck if you posted this in the VB .Net Forum. It doesn't sound like your even printing a report, your printing the form,
    tried using the scrollable print option on the print form component
    Though you should be using a report.

    Changing the size of the form and reportviewer wouldn't be hard, just change the size property. I don't know how you're retrieving your data, but you need to find a way to get the count of the line items in order to determine if you need to change the form size.

  7. #7
    Junior Member
    Join Date
    Nov 2013
    Location
    Ireland
    Posts
    25

    Exclamation Re: How to dynamically set page length in data report?

    Ive already tried to use the size property to fix my problem but it never made a difference, I have also tried to use auto size and disable the scroll bar but nothing has worked. I am using a reportviewer control that takes up the whole of the form. The code that I have behind the form is below:

    Code:
    Imports System.Data.OleDb
    Imports System.IO
    Imports System.Drawing.Printing
    
    Public Class Receipt
        Public PicLocation As String
        Dim Ctrl1, Ctrl2 As Control
        Dim CN As New OleDb.OleDbConnection
        Dim CMD As New OleDb.OleDbCommand
        Dim DataR As OleDb.OleDbDataReader
    
        'To display into datagrid purpose
        Dim dataS As New DataSet
        Dim dataAd As New OleDb.OleDbDataAdapter
        Public SqlStr, SqlStr1, DBPath, DBStatus, SearchBox As String
        Dim X, Y, SqlH, Onh As Integer
        Dim SqlUser As String
        Dim DataP As Decimal
        Dim Balance As Integer
    
        Private Sub Receipt_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            
            'TODO: This line of code loads data into the 'ProductListDataSet' table.
            DBPath = (Application.StartupPath & "\ProductList.accdb")
            If CN.State = ConnectionState.Open Then
                CN.Close()
                DBStatus = ("Not Connected")
            End If
            SqlStr = ("Provider = Microsoft.ACE.OLEDB.12.0;Data Source =" & DBPath)
            CN.ConnectionString = SqlStr
            CN.Open()
            Onh = Nothing
    
            lblTime.Text = DateAndTime.Now
            lblUser.Text = Login.userTB.Text
    
            Dim sql As String
            sql = "SELECT * Receipt"
            Me.ReceiptTableAdapter.ClearBeforeFill = True
            Me.ReceiptTableAdapter.Connection = CN
            Me.ReceiptTableAdapter.Connection.CreateCommand.CommandText = sql
            Me.ReceiptTableAdapter.Fill(Me.ProductListDataSet.Receipt)
            Me.ReportViewer1.RefreshReport()
            Me.Refresh()
    
          
        End Sub
    
        Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
    
            With Me.PrintForm1
                .PrintAction = Printing.PrintAction.PrintToPrinter
    
                Dim MyMargins As New Margins
                With MyMargins
                    .Left = 0
                    .Right = 0
                    .Top = 0
                    .Bottom = 0
                End With
                .PrinterSettings.DefaultPageSettings.Margins = MyMargins
                .Print(Me, PowerPacks.Printing.PrintForm.PrintOption.CompatibleModeClientAreaOnly)
    
            End With
    
        End Sub
    
    End Class

  8. #8
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,513

    Re: How to dynamically set page length in data report?

    It looks like your using the PrintForm control. Sorry, I've never used it. Seems like a report like rdlc/crystal/printdocument would work better. Maybe you can find some helpful information thru Google. Good luck.

  9. #9
    Junior Member
    Join Date
    Nov 2013
    Location
    Ireland
    Posts
    25

    Re: How to dynamically set page length in data report?

    I cant find anything through Google thats why I joined the forum.

    Ive tried using a PrintDocument control as well and I got more output using the PrintForm.

    Thanks anyway.

  10. #10
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: How to dynamically set page length in data report?

    Given that the data you have is already in a database table (or query) I think your best bet is to look at a reporting tool - either Crystal Reports or SSRS are the most commonly used.

    PrintForm is a bad choice as it only prints what is displayed on a form as it is displayed - so any cut-off records will not print.

    If you are feeling brave you can write your own print code using PrintDocument - it is quite involved but it does give you a very high degree of control over the results. In that case you should start by reading the Beginner's guide to printing in .NET

  11. #11
    Junior Member
    Join Date
    Nov 2013
    Location
    Ireland
    Posts
    25

    Re: How to dynamically set page length in data report?

    Thanks Merrion.

    I'll give that a go!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width