Results 1 to 4 of 4

Thread: [RESOLVED] One form all reports

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2004
    Location
    Arkansas
    Posts
    35

    Resolved [RESOLVED] One form all reports

    Hello,

    I am using VB6 and Crystal reports 9. I can create a report and view
    that report on my form without any problem but what I would like is to create one form to view all reports instead of placing a viewer on each form.
    I cannot figure out how to send the report information from my form to the
    viewer form. Any help or examples would greatly be appreciated.

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: One form all reports

    I have a form called crViewer. I have the viewer control on there.

    This is the code I use (for one report).

    [vbcode]
    Public Sub R_ClosuresByFoil()
    On Error GoTo errorhandler

    Dim PRINTREPLY As VbMsgBoxResult
    Dim printreply2 As VbMsgBoxResult
    PRINTREPLY = MsgBox("Print to screen?", vbYesNo)
    If PRINTREPLY = vbNo Then
    glbPrinterDestination = 1
    printreply2 = MsgBox("Print to file?", vbYesNo)
    If printreply2 = vbNo Then
    Else
    glbDate = InputBox("Start Date")
    glbDate1 = InputBox("End Date")
    glbPrinterDestination = 2
    End If
    Else
    glbPrinterDestination = 0
    End If
    Screen.MousePointer = vbHourglass
    Set Report = crxApplication.OpenReport("Z:\DAD\ClosuresByFoil.rpt", 1)
    For Each crxDatabaseTable In Report.Database.Tables
    crxDatabaseTable.ConnectionProperties("user id") = "sa"
    crxDatabaseTable.ConnectionProperties("Password") = myPasswordTechniSQL
    Next crxDatabaseTable
    Report.PaperOrientation = crDefaultPaperOrientation
    If glbPrinterDestination = 0 Then
    glbReportForm = "frmProduction"
    CRViewer.Show 1
    ElseIf glbPrinterDestination = 2 Then 'print to file
    Report.ParameterFields.Item(1).AddCurrentValue glbDate
    Report.ParameterFields.Item(2).AddCurrentValue glbDate1
    Report.ExportOptions.FormatType = crEFTExcel80Tabular
    Report.ExportOptions.DiskFileName = "C:\ClosuresByFoil.xls"
    Report.ExportOptions.DestinationType = crEDTDiskFile
    Report.Export False
    Else
    Report.PrintOut False
    End If
    Screen.MousePointer = 0

    Exit Sub
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    errorhandler:
    Screen.MousePointer = 0
    MsgBox "An error occurred: [" & Err.Number & "] " & Err.Description & " - Source: (frmProduction)R_ClosuresByFoil"

    End Sub
    [/vbcode]
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  3. #3
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: One form all reports

    In the crViewer form load I have this code
    [vbcode]
    Private Sub Form_Load()
    On Error GoTo errorhandler

    '#################
    With CRViewer91
    Select Case glbReportForm
    Case "frmActiveJobs"
    .ReportSource = frmActiveJobs.Report
    Case "frmAdditiveInventory"
    .ReportSource = frmAdditiveInventory.Report
    Case "frmAdditiveParam"
    .ReportSource = frmAdditiveParam.Report
    Case "frmArtWork"
    .ReportSource = frmArtWork.Report
    Case "frmBOL2"
    .ReportSource = frmBOL2.Report
    Case "frmBOLSelection"
    .ReportSource = frmBOLSelection.Report
    Case "frmBRSSelect"
    .ReportSource = frmBRSSelect.Report
    Case "frmCalendarDetails"
    .ReportSource = frmCalendarDetails.Report
    Case "frmCommonScreen"
    .ReportSource = frmCommonScreen.Report
    Case "frmCorrectiveAction"
    .ReportSource = frmCorrectiveAction.Report
    Case "frmCustJobData"
    .ReportSource = frmCustJobData.Report
    Case "frmCustomerColors"
    .ReportSource = frmCustomerColors.Report
    Case "frmCustomerList"
    .ReportSource = frmCustomerList.Report
    Case "frmCustomerQuery"
    .ReportSource = frmCustomerQuery.Report
    Case "frmDailyPostingRecap"
    .ReportSource = frmDailyPostingRecap.Report
    Case "frmDestroyAuth"
    .ReportSource = frmDestroyAuth.Report
    Case "frmEmployeeNumbers"
    .ReportSource = frmEmployeeNumbers.Report
    Case "frmEmployeeSelect"
    .ReportSource = frmEmployeeSelect.Report
    Case "frmGeneralArt"
    .ReportSource = frmGeneralArt.Report
    Case "frmGenericGrid"
    .ReportSource = frmGenericGrid.Report
    Case "frmHumanResources"
    .ReportSource = frmHumanResources.Report
    Case "frmInkMixed"
    .ReportSource = frmInkMixed.Report
    Case "frmInkSamples"
    .ReportSource = frmInkSamples.Report
    Case "frmJobHistory"
    .ReportSource = frmJobHistory.Report
    Case "frmJobSelect"
    .ReportSource = frmJobSelect.Report
    Case "frmLocation"
    .ReportSource = frmLocation.Report
    Case "frmMarketing"
    .ReportSource = frmMarketing.Report
    Case "frmMarquee"
    .ReportSource = frmMarquee.Report
    Case "frmNewJobs"
    .ReportSource = frmNewJobs.Report
    Case "frmPendingArt"
    .ReportSource = frmPendingArt.Report
    Case "frmPOQuery"
    .ReportSource = frmPOQuery.Report
    Case "frmPrePressSummary"
    .ReportSource = frmPrePressSummary.Report
    Case "frmProduction"
    .ReportSource = frmProduction.Report
    Case "frmPrinted"
    .ReportSource = frmPrinted.Report
    Case "frmPSOutOfSynch"
    .ReportSource = frmMarquee.Report
    Case "frmQCAlert"
    .ReportSource = frmQCAlert.Report
    Case "frmQCAlertList"
    .ReportSource = frmQCAlertList.Report
    Case "frmQCInspection"
    .ReportSource = frmQCInspection.Report
    Case "frmQCInspectionOut"
    .ReportSource = frmQCInspectionOut.Report
    Case "frmQuote"
    .ReportSource = frmQuote.Report
    Case "frmQuoteLog"
    .ReportSource = frmQuoteLog.Report
    Case "frmReceiptQuery"
    .ReportSource = frmReceiptQuery.Report
    Case "frmReceipts"
    .ReportSource = frmReceipts.Report
    Case "frmSampleBOL"
    .ReportSource = frmSampleBOL.Report
    Case "frmSamples"
    .ReportSource = frmSamples.Report
    Case "frmSelectTNumbers"
    .ReportSource = frmSelectTNumbers.Report
    Case "frmSelectArt"
    .ReportSource = frmSelectArt.Report
    Case "frmSpecSheet"
    .ReportSource = frmSpecSheet.Report
    Case "frmSpecSheet2"
    .ReportSource = frmScrnTNum.Report
    Case "frmTearDown"
    .ReportSource = frmTearDown.Report
    Case "frmThatcher"
    .ReportSource = frmThatcher.Report
    Case "frmTNumStockXREF"
    .ReportSource = frmTnumStockXREF.Report
    Case "frmTNumberList"
    .ReportSource = frmTNumberList.Report
    Case "frmTumblePack"
    .ReportSource = frmTumblePack.Report
    Case "frmUnprinted"
    .ReportSource = frmUnprinted.Report
    Case "frmViolation"
    .ReportSource = frmViolation.Report
    Case "QCSortingSummary"
    .ReportSource = frmProduction.Report
    End Select
    End With
    '################

    Screen.MousePointer = 0
    CRViewer91.ViewReport

    Exit Sub
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    errorhandler:
    Screen.MousePointer = 0
    MsgBox "An error occurred: [" & Err.Number & "] " & Err.Description & " - Source: (CRViewer)Form_Load"

    End Sub
    [/vbcode]
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  4. #4
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: One form all reports

    It may not be perfect, but it works.

    BTW; at the top of the form producing the report I have:

    [vbcdoe]
    Dim crxApplication As New CRAXDRT.Application
    Public Report As CRAXDRT.Report
    Dim crxDatabaseTable As CRAXDRT.DatabaseTable
    [/vbcode]
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

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