PDA

Click to See Complete Forum and Search --> : Printing the resultats (MSHFlexGrid)


Patrice Bourdages
Oct 4th, 2000, 08:45 AM
I need to be able to print the results from the following MSHFlexGrid. Read on...

Here's the actual code:

Option Explicit
Private Const MARGIN_SIZE = 60 ' en Twips
Private datPrimaryRS As ADODB.Recordset
-----------------------------------------------------
Private Sub Form_Load()
Dim sConnect As String
Dim sSQL As String
Dim dfwConn As ADODB.Connection
Dim i As Integer
' définir les chaînes
sConnect = "Provider=MSDASQL.1;Extended Properties='DSN=Concorde;Description=Projet Concorde;UID=;PWD=;APP=Visual Basic;WSID=IAGQ0040;DATABASE=Concorde;Network=DBMSSOCN;Address=iagsrvsql,1433;Trusted_Connection=Yes '"
'
' La chaine strChaineSQL provient de frmNbQtCn1
'
sSQL = strChaineSQL & " ORDER by TypeLot"
' ouvrir la connexion
Set dfwConn = New Connection
dfwConn.Open sConnect
' créer un jeu d'enregistrements à partir de la collection fournie
Set datPrimaryRS = New Recordset
datPrimaryRS.CursorLocation = adUseClient
datPrimaryRS.Open sSQL, dfwConn, adOpenForwardOnly, adLockReadOnly
If datPrimaryRS.RecordCount > 0 Then
Set MSHFlexGrid1.DataSource = datPrimaryRS
With MSHFlexGrid1
.Redraw = False
.TextMatrix(0, 0) = "Type"
.TextMatrix(0, 1) = "Année"
.TextMatrix(0, 2) = "Mois"
.TextMatrix(0, 3) = "Sem."
.TextMatrix(0, 4) = "Cie"
.TextMatrix(0, 5) = "Produit"
.TextMatrix(0, 6) = "N°Police"
.TextMatrix(0, 7) = "Tran. sys."
.TextMatrix(0, 8) = "Eff. Police"
.TextMatrix(0, 9) = "Prime"
.TextMatrix(0, 10) = "Agent"
.ColWidth(0) = 500
.ColWidth(1) = 650
.ColWidth(2) = 500
.ColWidth(3) = 500
.ColWidth(4) = 450
.ColWidth(5) = 700
.ColWidth(6) = -1
.ColWidth(7) = 1110
.ColWidth(8) = 1110
.ColWidth(9) = -1
.ColWidth(10) = 0
For i = 0 To .Cols - 1
.MergeCol(i) = True
Next i
.Sort = flexSortGenericAscending
.AllowBigSelection = True
.FillStyle = flexFillRepeat
.Row = 0
.Col = 0
.RowSel = .FixedRows - 1
.ColSel = .Cols - 1
.CellFontBold = True
For i = .FixedCols To .Cols() - 1 Step 2
.Col = i
.Row = .FixedRows
.RowSel = .rows - 1
.CellBackColor = &HC0C0C0 ' gris clair
Next i
.AllowBigSelection = False
.FillStyle = flexFillSingle
.Redraw = True
bolOkCharge = True
End With
Else
MsgBox "There is no data to view." & vbCrLf + vbCrLf & "Select another agent", vbExclamation
bolOkCharge = False
End If
End Sub


How do I go from there. I've added a menu to the form and created a small menu structure that would include printing options.

How do I add this feature from what's available here. I like the formating provided by MSHFlexGrid.

I've been searching for a few hours and I now give up. I need your help.

TIA

rikshawdriver
Apr 23rd, 2001, 03:08 AM
Try this

Printer.paintpicture MSHFlexGrid1.picture,0,0
Printer.enddoc

Also check the following sample code.

Private Sub cmdPrint_Click()
Const PAGE_WIDTH = 8.5 * 1440
Const PAGE_HEIGHT = 11 * 1440

Dim R As Integer
Dim C As Integer

For R = 0 To 1
For C = 0 To 1
With Printer
.ScaleLeft = R * PAGE_WIDTH
.ScaleTop = C * PAGE_HEIGHT
.ScaleWidth = PAGE_WIDTH
.ScaleHeight = PAGE_HEIGHT
End With

Printer.PaintPicture MSHFlexGrid1.Picture, 0, 0
Printer.NewPage
Next C
Next R
Printer.EndDoc

MsgBox "Ok"
End Sub

Patrice Bourdages
Apr 23rd, 2001, 07:31 AM
Thanks a bunch... :D

Really appreciate your help on this one... I'm glad there's an automated mailing stating that someone replied to our message. Have given hope's of an answer a long time ago...

Thanks again :p