printing record from VB form with Crystal Report 
Author Message
 printing record from VB form with Crystal Report

Does anyone have a sample code printing current data diplayed on the visual
basic form with Crystal Report.  I have the following code but it prints all
the data on the access database.  I know there is a way to make temp
database and fill the current data into the temp and print from there but I
am having problem accomplishing that.

Thanks for any help you can give me!!!

Sub DoPrint(intPrintStyle As Integer, intPreview As Integer)
Dim strReportName As String
Dim strPrintDB As String
Dim strFormula As String
Dim iResult As Integer

    If bReadyToPrint Then

        MDIMain.StatusBar1.Panels(1).Text = "Getting Ready To Print."

        Select Case intPrintStyle
            Case 0
                strReportName = App.Path & "\Customer_Info.rpt"
            Case 1
                strReportName = App.Path & "\Order_detail.rpt"
            Case 2
                strReportName = App.Path & "\Invoice.rpt"
                If MDIMain.mnuEditFixed.Caption = "Show Fixed" Then
                End If
        End Select

        If MDIMain.mnuEditFixed.Caption = "Hide Fixed" And intPrintStyle <>
2 Then
            MDIMain.StatusBar1.Panels(1).Text = "Hiding fixed items"
            MDIMain.StatusBar1.Panels(1).Text = "Getting Ready To Print"
        End If

        strFormula = "{TB_Customer.Customer_ID} = " &
        strPrintDB = App.Path & "\REData.mdb"

        MDIMain.StatusBar1.Panels(1).Text = "Printing"

        frmREntry.CrystalReport1.DataFiles(0) = strPrintDB
        frmREntry.CrystalReport1.ReportFileName = strReportName
        frmREntry.CrystalReport1.SelectionFormula = strFormula
        frmREntry.CrystalReport1.PrinterCopies = 1
        frmREntry.CrystalReport1.Destination = intPreview '0=print window,
1= printer
        iResult = frmREntry.CrystalReport1.PrintReport

        If iResult > 0 Then MsgBox "Print Error " & iResult

        Unload frmPrint

        MDIMain.StatusBar1.Panels(1).Text = ""
        MsgBox "Report Not Selected"
        Unload frmPrint
    End If

Exit Sub
    MsgBox "Error Printing Report. " & Err.Description
    MakeErrorLog "mnuFilePrintPreview", "frmREntry", Err.Description,
    Exit Sub

End Sub
Sub MakeErrorLog(strProcedure As String, strStep As String,
strErrDescription As String, intErrNumber As Integer)
Dim strDatabaseName As String
Dim x As String

strDatabaseName = App.Path & "\Errlog.txt"
x = Dir(strDatabaseName, vbDefault)
    Open strDatabaseName For Append As #1
        Print #1, Date & " " & Time
        Print #1, "Procedure: " & strProcedure
        Print #1, "Module or Table: " & strStep
        Print #1, "Error: " & strErrDescription
        Print #1, "Error #:" & intErrNumber
        Print #1, "Report #:" &
        Print #1, " "
    Close #1

End Sub

Wed, 07 Dec 2005 05:08:29 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Printing Crystal Reports without Crystal Control ActiveX or Crystal Reports API call

2. Can Crystal Report print a pre-printed form?

3. printing the same record multiple times in Crystal Reports

4. Printing a Crystal report In VB5 + finding record in DBGrid

5. Crystal Reports - Printing Last Record

6. Crystal Reports - Printing Last Record?

7. How to print certain records in bold using Crystal Reports 4.6

8. Crystal 7 report selects records but does not print

9. Print a specific record and desire date in Crystal report 7

10. how do I print only one record to crystal report

11. Crystal Reports ANd VB 6.0 Printing reports using CRPEAUTO Object, specifying paper orientation problem

12. Printing report from Dynaset using Crystal Report and VB


Powered by phpBB® Forum Software