Results 1 to 3 of 3

Thread: Report printing problem!!!

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    Report printing problem!!!

    Dear Friends,

    I got the code from the following link and pasted it in my project to get prints from datagrid. But I dont know whether I have done it properly. How can I take the print out from the datagrid. Could somebody help me in this regard.

    The following is the link from where I got the code:

    http://www.pscode.com/vb/scripts/Sho...31485&lngWId=1

    my project is also attached to review it.
    Attached Files Attached Files

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

    Re: Report printing problem!!!

    You say you don't know if you have done it properly.

    What results are you getting? (Are you getting any results?)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    Re: Report printing problem!!!

    Quote Originally Posted by Hack
    You say you don't know if you have done it properly.

    What results are you getting? (Are you getting any results?)
    The whole code is as follows:

    VB Code:
    1. Private Sub Command1_Click()
    2. imprimir
    3. End Sub
    4. Private Sub Form_Load()
    5. Call data_connect
    6. rs.Open "Select * from IRCTB1", db
    7. Set DataGrid1.DataSource = rs
    8. DataGrid1.Height = 5565
    9. DataGrid1.RowHeight = 400
    10. show_rec
    11. End Sub
    12. Public Sub show_rec()
    13. Text1 = rs(0)
    14. Text2 = rs(1)
    15. Text3 = rs(2)
    16. End Sub
    17. Public Function imprimir(ByVal datos As DataGrid, ByVal datas As Adodc, ByVal tit As String) As Long
    18.     Dim MyRows, MyCols As Integer 'for-loop counters
    19.     Dim MyText As String 'text To be printed
    20.     Dim Titles As String 'column titles
    21.     Dim Header As String 'page headers
    22.     Dim MyLines As Integer 'number of lines For portrait
    23.     Dim LLCount As Integer 'temporary line counter
    24.     Dim MyArray(20) As Integer
    25.     Dim Rowado, Rowdatag As Integer
    26.     Dim Mtittle As String
    27.    
    28.     Screen.MousePointer = vbHourglass
    29.     Titles = ""
    30.     LLCount = 0
    31.     Mtitle = Space(40) & tit
    32.     Header = " - Page: " 'setup page header
    33.     'get column headers
    34.  
    35.  
    36.     For MyCols = 1 To datos.Columns.Count
    37.         MyArray(MyCols) = Len(datos.Columns(MyCols - 1).Caption) + 10
    38.         Titles = Titles & Space(10) & datos.Columns(MyCols - 1).Caption
    39.     Next MyCols
    40.     'setup printer
    41.     Printer.Font.Size = 8 '8pts font size
    42.     Printer.Font.Bold = True 'titles To be bold
    43.     Printer.Font.Name = "Courier New" 'courier new font
    44.     Printer.Orientation = vbPRORPortrait
    45.     MyLines = 82
    46.     Printer.Print Mtitle
    47.     Printer.Print Header; Printer.Page
    48.     Printer.Print Titles
    49.     Printer.Font.Bold = False
    50.     'get column/row values
    51.     datas.Refresh
    52.     datos.Refresh
    53.  
    54.  
    55.     For Rowado = 1 To Int((datas.Recordset.RecordCount - 1) / 13) + 1
    56.  
    57.  
    58.         For Rowdatag = 0 To datos.VisibleRows - 1
    59.             datos.RowBookmark (Rowdatag)
    60.             MyText = Space(10)
    61.  
    62.  
    63.             For MyCols = 1 To datos.Columns.Count
    64.                 [B]MyText = MyText & datos.Columns(MyCols - 1).CellText(datos.Bookmark) &[/B] [I]>>> [U]the bold text is shown in RED COLOR[/U][/I]                Space (MyArray(MyCols) - Len(datos.Columns(MyCols - 1).CellText(datos.Bookmark)))
    65.             Next MyCols
    66.             LLCount = LLCount + 1
    67.  
    68.  
    69.             If LLCount <= MyLines Then
    70.                 Printer.Print MyText
    71.             Else
    72.                 Printer.NewPage
    73.                 Printer.Print Mtitle
    74.                 Printer.Print Header; Printer.Page
    75.                 Printer.Print Titles
    76.                 Printer.Print MyText
    77.                 LLCount = 0
    78.             End If
    79.             datas.Recordset.MoveNext
    80.         Next Rowdatag
    81.         datos.Scroll 0, datos.VisibleRows
    82.     Next Rowado
    83.     Printer.Print " "
    84.     Printer.EndDoc
    85.     Screen.MousePointer = vbNormal
    86. End Function

    and the error pops up : argument not optional then highlights the following line:

    [Highlight=VB]Private Sub Command1_Click()
    imprimir

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