Results 1 to 14 of 14

Thread: Printing rows in a flex grid!!!Help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Wolverhampton, England
    Posts
    218

    Printing rows in a flex grid!!!Help

    I need to print off rows in a MS Flex Grid returned from an embedded SQL query. I can at the moment print each row off using a for loop:
    Private Sub cmdPrint_Click()
    Dim PrintString As String, iRows As Integer, jCols As Integer

    For iRows = 0 To fgStudentDetails.Rows - 1
    PrintString = ""

    For jCols = 0 To fgStudentDetails.Cols - 1
    PrintString = PrintString & fgStudentDetails.TextMatrix(iRows, jCols)
    If jCols < fgStudentDetails.Cols - 1 Then
    PrintString = PrintString & ","
    End If
    Next
    Printer.Print PrintString
    Printer.EndDoc
    Next

    End Sub

    However, the end result is a rather unsitely list of whatever is in the flex grid separated by comma's. I need to do formatting commands for EACH row that is returned but am unsure of where to incorporate them in the above query. Things like orientation, scalemode, currentX and Y, etc etc.

    Can anyone assist me? I have searched the forums to no avail!!

    Please help, i know there are people with considerable knowledge !!

    Many thx in advance

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Wolverhampton, England
    Posts
    218
    I am desperate!! If anyone could ASSIST it would be much obliged!

  3. #3
    Megatron
    Guest
    Try:
    Code:
    Printer.PaintPicture MSFlexGrid1.Picture

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Wolverhampton, England
    Posts
    218

    Megatron

    That code simply prints of a picture of the flexgrid as a whole. I do not need that unfortunately, but each INDIVIDUAL ROW of the flex grid, and then do formatting commands in the code stipulated above.

    Thanks for the reply anyhow, but have u any other ideas?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Wolverhampton, England
    Posts
    218

    Martin Bliss

    I know you know the answer to my query!! It may be simple in ur eyes, but if you could help it would be very much appreciated!!

    Or am i being cheeky?

    Cheers

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Wolverhampton, England
    Posts
    218

    desperate

    I am going to ask sorry beg once more to see if any body can assist with the 1st query stipulated above. Anybody? I know it is awkward but i know there are people in here who have the ability to do this or know the answer.

    Many thx in advance.

  7. #7
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    To loops one for the number of pages, one for the number of rows to print on each page...

    This is a rather lengthy snippet, using a print preview control, so you will have to substitute as needed...

    VB Code:
    1. '*******************************************************************************
    2. ' DOREPORT1 (SUB)
    3. '
    4. ' DESCRIPTION:
    5. ' PREVIEW EMPLOYEE LISTING
    6. '*******************************************************************************
    7.  
    8. Private Sub DOREPORT1(OutputMode As Integer)
    9.    
    10.     Me.MousePointer = vbHourglass
    11.    
    12.     Set SWBPrintEngine = New SWBPrinter
    13.    
    14.     SWBPrintEngine.BeginDoc
    15.    
    16.     SWBPrintEngine.ScaleMode = vbTwips
    17.    
    18.     SWBPrintEngine.Orientation = vbPRORPortrait
    19.    
    20.     SWBPrintEngine.ShowPreviewSave = False
    21.    
    22.     SWBPrintEngine.ZoomPercent = -2
    23.    
    24.     SWBPrintEngine.CloseButtonCaption = "Close Preview"
    25.    
    26.     SWBPrintEngine.ShowProgress = False
    27.    
    28.     ' KILLS OFF CANCEL OFF PRINT
    29.    
    30.     SWBPrintEngine.ShowPrintDialog = False
    31.    
    32.     SWBPrintEngine.DefaultPrinter = Printer.DeviceName
    33.    
    34.     SWBPrintEngine.PrintCopies = 1
    35.    
    36.     SWBPrintEngine.PrintFromPage = 1
    37.    
    38.     SWBPrintEngine.PrintToPage = 10000
    39.    
    40.     ' START THE PRINT ROUTINE
    41.    
    42.     Dim TROWS, DPAGES, IPAGES, TPAGES, ENDNUM As Long
    43.    
    44.     Dim X As Integer
    45.    
    46.     Dim Y As Integer
    47.    
    48.     Dim NXTROW As Integer
    49.    
    50.     ' DETERMINES NUMBER OF RECORDS DIVISIBLE BY 40 AND REMAINDER
    51.    
    52.     ' COLUMN HEADINGS AND BLANK LINE
    53.    
    54.     TROWS = Me.MSFlexGrid1.Rows - 1
    55.    
    56.     ' 35 LINES PER SHEET
    57.    
    58.     DPAGES = TROWS / 35
    59.    
    60.     IPAGES = Int(DPAGES)
    61.    
    62.     ' DETERMINE NUMBER OF PAGES FOR PRINT
    63.    
    64.     If DPAGES - IPAGES = 0 Then
    65.        
    66.         TPAGES = DPAGES
    67.        
    68.     Else
    69.        
    70.         TPAGES = IPAGES + 1
    71.        
    72.     End If
    73.    
    74.     ' SETUP GLOBAL FOR PRINTER
    75.    
    76.     SWBPrintEngine.SetFont "TAHOMA", 10, 0
    77.    
    78.     ' BEGIN LOOP FOR PAGES
    79.    
    80.     For X = 1 To TPAGES
    81.        
    82.         ' BEGIN HEADER INFORMATION
    83.        
    84.         SWBPrintEngine.SetFont "TAHOMA", 12, 1 + 4
    85.        
    86.         SWBPrintEngine.ImageOut STRGBLSTTYPPATH & "STLogoBW.bmp", 400, 350, 1300, 900
    87.        
    88.         SWBPrintEngine.Y = 400
    89.         SWBPrintEngine.TextOut 1850, "Employee Listing"
    90.        
    91.         SWBPrintEngine.Y = 725
    92.         SWBPrintEngine.TextOut 1850, "(" & Mid(Me.lblBold(0).Caption, 20, 1000) & ")"
    93.        
    94.         ' FONT CHANGE ===========================
    95.        
    96.         SWBPrintEngine.SetFont "TAHOMA", 9, 0
    97.        
    98.         SWBPrintEngine.Y = 1100
    99.         SWBPrintEngine.TextOut 1850, "as of : " & Now
    100.        
    101.         ' FONT CHANGE ===========================
    102.        
    103.         SWBPrintEngine.SetFont "TAHOMA", 9, 2
    104.        
    105.         ' BOX FOR LOCATION INFO
    106.        
    107.         SWBPrintEngine.BoxOut 5400, 450, 11800, 1850
    108.        
    109.         ' FONT CHANGE ===========================
    110.        
    111.         SWBPrintEngine.SetFont "TAHOMA", 9, 2
    112.        
    113.         SWBPrintEngine.Y = 600
    114.         SWBPrintEngine.TextOut 5600, "Location:"
    115.        
    116.         ' FONT CHANGE ===========================
    117.        
    118.         SWBPrintEngine.SetFont "TAHOMA", 9, 0
    119.        
    120.         SWBPrintEngine.Y = 600
    121.         SWBPrintEngine.TextOut 6800, GBLLOCATID
    122.        
    123.         SWBPrintEngine.Y = 900
    124.         SWBPrintEngine.TextOut 6800, GBLPROJECT
    125.        
    126.         SWBPrintEngine.Y = 1200
    127.         SWBPrintEngine.TextOut 6800, GBLPADDRESS
    128.        
    129.         SWBPrintEngine.Y = 1500
    130.         SWBPrintEngine.TextOut 6800, GBLPCITYSTATE & "      " & GBLPZIP
    131.        
    132.         ' BOX TO WRAP EMPLOYEES
    133.        
    134.         SWBPrintEngine.BoxOut 450, 2200, 11800, 14600
    135.        
    136.         ' PRINT COLUMN HEADINGS
    137.        
    138.         ' LINE NUMBER
    139.        
    140.         SWBPrintEngine.Y = 2450
    141.         SWBPrintEngine.TextOut 600, "No."
    142.        
    143.         ' EMPLOYEE NAME
    144.        
    145.         SWBPrintEngine.Y = 2450
    146.         SWBPrintEngine.TextOut 1700, "Employee Full Name"
    147.        
    148.         ' SSN
    149.        
    150.         SWBPrintEngine.Y = 2450
    151.         SWBPrintEngine.TextOut 4700, "Work ID / S.S.N."
    152.        
    153.         ' ECODE
    154.        
    155.         SWBPrintEngine.Y = 2450
    156.         SWBPrintEngine.TextOut 6800, "Pay Class"
    157.        
    158.         ' ENTRY TYPE
    159.        
    160.         SWBPrintEngine.Y = 2450
    161.         SWBPrintEngine.TextOut 8700, "Work Status"
    162.        
    163.         SWBPrintEngine.SetFont "TAHOMA", 9, 0
    164.        
    165.         ' DETERMINES WHERE TO STOP THE LOOP
    166.        
    167.         If X = TPAGES Then
    168.            
    169.             ENDNUM = TROWS
    170.            
    171.         Else
    172.            
    173.             ENDNUM = 35 * X
    174.            
    175.         End If
    176.        
    177.         ' FOR LOOP TO CREATE PAGES TO PRINT
    178.         ' (35 INDICATES NUMBER OF RECORDS TO PRINT ON PAGE)
    179.        
    180.         For Y = 1 + (35 * (X - 1)) To ENDNUM
    181.            
    182.             ' DETERMINES WHERE TO SET CURRENTY POSITION W/ REGARD TO NEXT SHEET
    183.            
    184.             If X > 1 Then
    185.                
    186.                 NXTROW = 335 * (Y - (35 * (X - 1)))
    187.                
    188.             Else
    189.                
    190.                 NXTROW = 335 * Y
    191.                
    192.             End If
    193.            
    194.             ' BUILDS THE TABLE DETERMINED BY CURRENTX AND CURRENTY,
    195.             ' ALONG WITH ROW AND SHEET CONSIDERATION
    196.            
    197.             ' LINE NUMBER
    198.            
    199.             SWBPrintEngine.Y = 2500 + NXTROW
    200.             SWBPrintEngine.TextOut 600, Y
    201.            
    202.             ' EMPLOYEE NAME
    203.            
    204.             SWBPrintEngine.Y = 2500 + NXTROW
    205.             SWBPrintEngine.TextOut 1700, Me.MSFlexGrid1.TextMatrix(Y, 1)
    206.            
    207.             ' SSN
    208.            
    209.             SWBPrintEngine.Y = 2500 + NXTROW
    210.             SWBPrintEngine.TextOut 4700, Me.MSFlexGrid1.TextMatrix(Y, 2)
    211.            
    212.             ' ECODE
    213.            
    214.             SWBPrintEngine.Y = 2500 + NXTROW
    215.             SWBPrintEngine.TextOut 6800, Me.MSFlexGrid1.TextMatrix(Y, 3)
    216.            
    217.             ' ENTRY TYPE
    218.            
    219.             SWBPrintEngine.Y = 2500 + NXTROW
    220.             SWBPrintEngine.TextOut 8700, Me.MSFlexGrid1.TextMatrix(Y, 4)
    221.            
    222.         Next Y
    223.        
    224.         ' BOX FOR STATUS
    225.        
    226.         SWBPrintEngine.BoxOut 450, 15000, 11800, 15400
    227.        
    228.         SWBPrintEngine.SetFont "TAHOMA", 9, 0
    229.        
    230.         ' PRINT FOOTER INFO
    231.        
    232.         SWBPrintEngine.Y = 15100
    233.         SWBPrintEngine.TextOut 600, COPYRIGHTNOTICE
    234.        
    235.         SWBPrintEngine.Y = 15100
    236.         SWBPrintEngine.TextOut 10500, "Page " & X & " of " & TPAGES
    237.        
    238.         If X <> TPAGES Then
    239.            
    240.             SWBPrintEngine.NewPage
    241.            
    242.         End If
    243.        
    244.     Next X
    245.    
    246.     SWBPrintEngine.EndDoc
    247.    
    248.     ' DETERMINE WHETHER TO PRINT OR PREVIEW
    249.    
    250.     If (OutputMode = PREVIEW_REPORT) Then
    251.        
    252.         SWBPrintEngine.PreviewReport
    253.        
    254.     Else
    255.        
    256.         SWBPrintEngine.PrintReport
    257.        
    258.     End If
    259.    
    260.     Me.MousePointer = vbDefault
    261.    
    262. End Sub

    Most of this code can be changed to fit your need...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  8. #8
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Got your PM.

    What I do is place a image in a cell t indicate user has selected the line to include in the print. I use a label to display the count everytime the user selects the grid.

    When printing :

    Add all rows data into an array that has the image within the cell (means it was selected)...

    Now loop for the number of selected and call your print routine...

    f you need furthur help, send me your project. I should be able to implement fairly easily (as long as you have the print routine written )
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Wolverhampton, England
    Posts
    218

    James

    Check ur email (hotmail).

  10. #10
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Re: James

    Originally posted by karolmcauley
    Check ur email (hotmail).
    I need login credentials...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Wolverhampton, England
    Posts
    218

    James

    What do you mean!

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Wolverhampton, England
    Posts
    218

    James

    What do you mean?

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Wolverhampton, England
    Posts
    218

    James

    What do u mean???

  14. #14
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    ok...

    i know this is a real old thread, but:

    VB Code:
    1. Set SWBPrintEngine = New SWBPrinter

    what referencies do i need to add to be able to use the swbprinter ?

    tnx.,
    Wayne

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