Link to home
Start Free TrialLog in
Avatar of nkunapaneni
nkunapaneni

asked on

Visual Basic - Crystal Report

I want to create report with the data i have in a True DB grid.



' My True DBGrid control - is a bound grid.

gsSqlStmt = "SELECT DateReceived FROM WorkOrder WHERE DateReceived > '8/1/01' and Datereceived < '8/30/01'
gsSqlStmt = gsSqlStmt & "Group BY DateReceived"
Set rdatCust.Resultset = grdoDTI.OpenResultset(gsSqlStmt, rdOpenStatic, rdConcurReadOnly)
 tdbgrdCust.Refresh

' (I have 1 bound column and 3 unbound columns. To fill the unbound columns i am using unboundcolumnfetch event of true db grid.

Private Sub tdbgrdCust_UnboundColumnFetch(Bookmark As Variant, ByVal Col As Integer, Value As Variant)
        Dim rrsTmp As rdoResultset
        Select Case Col
            Case 1
                gsSqlStmt = "SELECT COUNT(WorkOrderID) FROM WorkOrder WHERE DateReceived = '" & tdbgrdCust.Columns("DateReceived").CellText(Bookmark) & "'"
                Set rrsTmp = grdoDTI.OpenResultset(gsSqlStmt, rdOpenStatic, rdConcurReadOnly)
                If Not rrsTmp.EOF Then
                    Value = rrsTmp.rdoColumns(0).Value
                Else
                    Value = 0
                End If
            Case 2
               ' Some code like above to get value
            Case 3
                ' Some code like above to get value
        End Select
    Exit Sub
End Sub


' Then i am calling a routine to print the report
private sub PrintReport()
     'I set the crystal report control property
   CrystalReport1.ReportSource = crptTrueDBGrid
   CrystalReport1.ReportFileName = App.Path & "\Reports\" & "GRDRPT1.rpt"
   CrystalReport1.ReportSource = crptTrueDBGrid
   CrystalReport1.Destination =1
   CrystalReport1.Action = 1
end sub
   

' When  i am doing this -
Unbound column fetch event is firing again after    CrystalReport1.Action = 1

This is giving me the error:
Error: 40027
Application-deifned or object-defined error

Can any one help me why this is happening.

Thanks .
   
Avatar of trkcorp
trkcorp

Just a thought... have you considered using the print functionality inherent to True Grid?  You can very easily print an image of the grid with the printdata method.  There is a nice preview option available and you have a great deal of control over your output.  You can state headings, add page numbers, etceteras...  Taking this path you have to do very little other than invoke the method and set a few properties.
Avatar of nkunapaneni

ASKER

HI
Thanks for the suggestion. I tried to use the
tdbgrid.PrintInfo.PrintData to print (.PrintPReview - to preview).  When i preview it -
I am able to get the preview properly.
But when i print - The data in the unbound columns is lost.
That's really wierd.
Do you have any suggestions on this.
Thanks.
That is really weird. I have done this many times and have never experienced anything like that and yes, I have had unbound columns and code very much like yours.  What version of TDBGrid are you using?  Have you applied the updates available from http://www.componentone.com/ I think I would if I hadn't...
The one i am using is
APEX True DBGrid Pro 6.0c

I don't think that i have applied any updates to it.
Can you suggest which one should i be considering?

Thanks.
Nalini.
ASKER CERTIFIED SOLUTION
Avatar of trkcorp
trkcorp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I got the update from the site. Now it is printing properly.
 Thanks alot for the help.

Nalini.
You are quite welcome.  That True Grid print option has come in handy many times for simple reports.  :)