Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2004
    Posts
    18

    Unanswered: 3 crystal reports

    I have a report that I call from a vb application. I need to print 3 copies with the only difference being a text field change in the footer section. (ie I need the original (MyCopy), (YourCopy), (TheirCopy))

    So instead of creating and calling three seperate reports, I would like to know how to do this with the report I have so I have only one change to make when modification time comes.

    Thanks.

  2. #2
    Join Date
    Oct 2005
    Posts
    178
    Quote Originally Posted by McF
    I have a report that I call from a vb application. I need to print 3 copies with the only difference being a text field change in the footer section. (ie I need the original (MyCopy), (YourCopy), (TheirCopy))

    So instead of creating and calling three seperate reports, I would like to know how to do this with the report I have so I have only one change to make when modification time comes.

    Thanks.
    you probably can do this..if you are not using the "ReportTitle" function in your crystal report form.

    In your vb application in your crystal object routine command to print

    use the crystal property "ReportTitle", since they are the same report, when you loop the print command for 3 pages, change the reporttitle text property value to the text you want.

    in your crystal report report form, insert the ReporTitle property at the bottom of the page.

    something like this

    Code:
    Private Sub Command1_Click()
    ReportPath = "C:\myReport.rpt"
    Dim pagenumber As Integer
    pagenumber = 0
    With CrystalReport1
    
    .ReportFileName = ReportPath
    
    For pagenumber = 1 To 3
    
    If pagenumber = 1 Then
    .ReportTitle = "My copy"
    ElseIf pagenumber = 2 Then
    .ReportTitle = "Your Copy"
    ElseIf pagenumber = 3 Then
    .ReportTitle = "Their copy"
    End If
    .PrintReport
    Next
    End With
    End Sub
    Last edited by fredservillon; 12-14-05 at 14:19.

  3. #3
    Join Date
    Nov 2004
    Posts
    18
    this would probably work but I can't use .ReportTitle as a property of cr9 in code, however, if I type it in (it's not in the list), vb recognizes it and capitalizes appropriatley.

    Run program and it quickly lets me know that it isn't a property.

    What gives and thanks for your reply/advice.

  4. #4
    Join Date
    Oct 2005
    Posts
    178
    Make sure in your vb design you have the references and components checked for crystal report. and you have the crystal object in form VB designed form

    In Crystal Report design form the ReportTitle can found under Special Insert option

    I just tried the code I gave you and it worked!
    Last edited by fredservillon; 12-14-05 at 20:53.

  5. #5
    Join Date
    Mar 2004
    Location
    Pakistan
    Posts
    31

    Lightbulb

    I m assuming you are using crystal report 8, not crystal reprot desinger
    create a parameter field and place it in reprot footer
    now you have to provide runtime parameter values from vb6 using cryastal report activex/ocx control

    pasate this code in your vb


    dim ReportNo as integer


    For ReportNo= 1 To 3


    if reportn = 1 then
    CR.ParameterFields(0)= "My City"
    elseif reportno = 2 then
    CR.ParameterFields(0)= "Your City"
    elseif reportno = 3 then
    CR.ParameterFields(0)= "Their City"

    End if

    CR.PrintReport
    next ReportNo

    try it





    try it
    Last edited by wasimshah; 12-20-05 at 03:25.

  6. #6
    Join Date
    Oct 2005
    Posts
    178
    OK, here's your solution
    In your crystal report name your parameter for example my example here is showing "PageQ"
    then in your VB routine ,modify your code to this (below)
    Code:
    Private Sub Command1_Click()
    ReportPath = "C:\myreport.rpt"
    Dim ReportNo As Integer
    With CR
    .ReportFileName = ReportPath
    
    For ReportNo = 1 To 3
    If ReportNo = 1 Then
    .ParameterFields(0) = "PageQ;" & "My City" & ";True"
    ElseIf ReportNo = 2 Then
    .ParameterFields(0) = "PageQ;" & "your City" & ";True"
    ElseIf ReportNo = 3 Then
    .ParameterFields(0) = "PageQ;" & "their City" & ";True"
    End If
    .PrintReport
    Next ReportNo
    End With
    End Sub
    I tried it and it worked
    Last edited by fredservillon; 12-21-05 at 12:39.

  7. #7
    Join Date
    Nov 2004
    Posts
    18
    Code:
    Private Sub SpecialPrint(Repname As String)
      
        Dim pagenumber As Integer
            pagenumber = 0
            
        Load Form9
        Unload Form9
      
        Set CRRep = crApp.OpenReport(VRepPath & Repname)
        
        CRRep.ReadRecords
    
        With Form1JUA.CrystalReport1
            .ReportSource = CRRep
        End With
        
        With CRRep
            
            For pagenumber = 1 To 3
                If (pagenumber = 1) Then
                    .ParameterFields(0) = "copy;JUA Copy;true"
                ElseIf (pagenumber = 2) Then
                    .ParameterFields(0) = "copy;Agent Copy;true"
                ElseIf (pagenumber = 3) Then
                    .ParameterFields(0) = "copy;Insured Copy;true"
                End If
                
            Next
            
            With Form1JUA.CrystalReport1
                .ViewReport
            End With
        
        End With
    
    End Sub
    what am I doing wrong???
    Last edited by McF; 12-30-05 at 20:08.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •